vim Substitution

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any vim Question?