OpenWindows Advanced User's Guide

6.7.3 Replacing a Character String

The procedure for replacing a text string is based on the search procedures discussed above. All the special matching characters for searches can be used in search-and-replace.

The basic command form is:


followed by the Return key.

Therefore, to replace every occurrence of the string "disinformation" with "newspeak", you would type:


and press Return.

You can modify this command to halt the search and make vi query whether you want to make the replacement in each instance. The following command uses gc (adding c for "consult") to make vi stop at every occurrence of "disinformation" and ask whether you want to make the substitution. Respond with y for yes or n for no.


Note -

You can cancel a "consulted" search-and-replace by pressing Ctrl-C.