Regular expressions, and their use with the substitute command, are what give vi most of its significant editing power.
The general form of the substitute command is:
Omitting the search pattern
uses the last search or substitution regular expression.
An empty replacement part
“replaces” the matched text with nothing, effectively deleting it from
Confirm each substitution
Change all occurrences of old to new on each line (globally)
Print the line after the change is made
It’s often useful to combine the substitute command with the
ex global command,
:g/Object Oriented/s//Buzzword compliant/g
(period) Matches any single character except a newline. Remember that spaces are treated as characters.
Matches zero or more (as many as there are) of the single character that immediately precedes it.
* can follow a metacharacter, such as
., or a range in brackets.
When used at the start of a regular expression,
^ requires that the following regular
expression be found at the beginning of the line. When not at the
beginning of a regular expression,
^ stands for
When used at the end of a regular expression,
$ requires that the preceding regular
expression be found at the end of the line. When not at the end of
a regular expression,
$ stands for
Treats the following special character ...