vimSubstitution


Syntax

  • s/<pattern>/<pattern>/optional-flags
  • <pattern> is a Regex

Parameters

FlagMeaning
&Keep the flags from the previous substitute.
cPrompt to confirm each substitution.
eDo not report errors.
gReplace all occurrences in the line.
iCase-insensitive matching.
ICase-sensitive matching.
nReport the number of matches, do not actually substitute.

Remarks

Use set gdefault to avoid having to specify the 'g' flag on every substitute.

Example

When gdefault is set, running :s/foo/bar on the line foo baz foo will yield bar baz bar instead of bar baz foo.