vim is the much-loved text editor when it comes to the command line or the terminal, but it has a learning curve when it comes to performing normal day-to-day operations like find and replace.
Let us take a look at various ways to perform find and replace operation using the:s substitution command,
Find and Replace 1st occurrence in a Line
:/s/sample/example


Find and Replace all occurrences of in a Line
:/s/line/line1/s


Find and Replace All occurrences of in a File
:%s/Say/Hello


-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to vi,
- Guide: Install Vim on Mac
- How to Uninstall Vim on Mac?
- How to update VIM version on a Mac
- How to Copy all text to Clipboard in Vim
- How to Select All Text in Vim/Vi editor
- How to perform Find and Replace using vim Editor
- Fix :wq! Vi Error - E32: No file name (when write and quit)
- How to add Colors to VIM (syntax highlighting)
More Posts:
- jQuery: Check if an element exists or not - jQuery
- [Solution] Spring Tool Suite (STS) support for JSP (JAVA EE) - Eclipse
- Install Python on Alpine Linux - Docker - Docker
- YAML Parser using Java Jackson Library Example - Java
- How to Configure GitHub with Eclipse IDE in 2023 - Eclipse
- Java 8: Steam map with Code Examples - Java
- How to pretty print HTML using Java Code - Html
- [Fix] Microsoft Windows OneDrive 0x8007018b Error Code - Windows