Find and Replace
Replace with or without Regular Expressions
This substitute command can use Regular Expressions and will match any instance of
foo followed by any( one ) character since the period
. in Regular Expressions matches any character, hence the following command will match all instances of
foo followed by any character in the current line.
If you want to match the literal
. period you can escape it in the search field with a backslash
Or disable all pattern matching by following the
s command with
will raise an error
substitutes each occurrence of
bar on the current line.
If you leave off the last
/g, it will only replace the first occurence on the line. For example,
On the previous line would become
performs the same substitution in lines 5 through 10.
performs the same substitution from line 5 to the end of the file.
performs the same substitution on the whole buffer.
If you are in visual mode and hit the colon, the symbol
will appear. You can then do this
and have the substitution occur within your visual mode selection.
is equivalent to the command above but asks for confirmation on each occurence thanks to the
/c flag (for "confirmation").
:help :s and
See also this section on command-line ranges.