Search and replace in vi

vi search and replace:

The following strings illustrate how to perform a search and replace in the Unix vi editor.

g/---/s//new_string/g

Replace EOL (end of line)

g/$/s//new_string/g

where $ is EOL and \t =

The start of line can be equally easily searched and replaced - using the carat ^ symbol.