How do I find and replace all string occurrences within entire text file using vim editor?

Answer Vi editor is based on ex the original ex editor written back in 1976. One of the features inherited from this editor is a way simply search and replace any string withing either single line, first occurrences or in entire text. Here are few examples: Replace a first occurrence of word vim for the word vi on the current line.


Substitute first occurrence on each line of the word vim for the word vi


Lastly, substitute every occurrence of the word vim for the word vim on all lines


Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top