Posts Tagged ‘substitute’

Search and replace with VI

Wednesday, February 25th, 2009

To search and replace in VI, you have to use the “substitute” command, which looks like this: [range]s/[search_string]/[replacement_string]/[options] Examples To search and replace all occurrences of OLD with NEW, type: :%s/OLD/NEW/g To search and replace all occurrences of OLD with NEW and ask for confirmation with each substitution, type: :%s/OLD/NEW/gc To search and replace all [...]