Home » Software Development » Editor » Vim » Find and Replace in VIM Editor

# Find and Replace in VIM Editor

Suppose we have a text file from which we want to search for string “hello” and replace it with “hi” , then below commands shows how to do find and replace in vim editor for different scenarios.

Search for First Occurrence in a Single Line and Replace it.

Go to the line from which we need to find and replace first occurance and type below,

``:s/hello/hi/``

So, for example if we have a line “say hello hello !” then above command will make it as “say hi hello!”

Search for All Occurrences in a Single Line and Replace it.

Just pass, “g” at the end of command used for replacing first occurrence.

``:s/hello/hi/g``

So, for example if we have a line “say hello hello !” then above command will make it as “say hi hi!”

Windows search text in files and fo...
Windows search text in files and folders with Notepad++