One minute
Vim for Intermediate Users
Find and Replace in Vim
Find and Replace in a line
While in the Normal mode press : to go into Command mode
Suppose you want to replace the word himanshu with the word goswami
:s/himanshu/goswami/
The above will replace the first instance of himanshu in the line
:s/himanshu/goswami/g
it will replace all instances of himanshu in the line with goswami
:s/himanshu/goswami/gc
For each instance of himanshu this will ask for yes/no whether you want to replace
Press y -> to replace and n-> don’t replace and move to next one
Find and Replace in the entire document
:%s/himanshu/goswami/
:%s/himanshu/goswami/g
Here both of them will replace all instances of himanshu in the file to goswami
For deleting the first instances go to that line and use: :s/himanshu/goswami/
:%s/himanshu/goswami/gc
For each instance of himanshu in the entire file this will ask for yes/no, whether you want to replace