Vim : how do I search and replace text

By | September 16, 2011

Do the following to find and replace text string in a whole file using the Vi text editor :

1. Enter in command mode by typing ” :

2. Your command should look like this :

:%s/search_for_text/replace_with_this_text/g

NOTE : To search & replace a string containing slashes ” / “, use a coma ” , ” instead :

:%s,search/for/text,replace/with/this/text,g