You are herevi Editor

vi Editor


Searching and Replacing with vi Editor

:g/string1/s//string2/g (there are other ways to do this search and replace, as you will find if you get more involved with vi)

Replace all occurences of string1 with string2. The combinations of / and . can be used for a walk through search and replace.

For example, want to replace forearm with forearc:

;g/forearm/s//forearc/g

For example, you want to replace all periods in a file with commas:
:g/\./s//\,/g

Example you want to replace german umlauts with the HTML Code:
The \ sign is needed to parse the & as a character and not a command.

:g/ä/s//\ä/g
:g/ö/s//\ö/g
:g/ü/s//\ü/g
:g/Ä/s//\Ä/g
:g/Ö/s//\Ö/g
:g/Ü/s//\Ü/g