Skip to content

Instantly share code, notes, and snippets.

@alienlebarge
Created October 4, 2018 04:51
Show Gist options
  • Save alienlebarge/0c34edc0f695ff2490a8cf62251aa252 to your computer and use it in GitHub Desktop.
Save alienlebarge/0c34edc0f695ff2490a8cf62251aa252 to your computer and use it in GitHub Desktop.
:[range] s[ubstitute]/pattern/string/[flags] [count]

Everything enclosed between [] in this command is optional.

range

Range can be:

  • 28 - line 28
  • 1 - first line
  • $ - last line
  • % - all lines in a file (same as 1,$)
  • 11,$ - line 11 to end of the file
  • .,$ - current line to end of the file
  • .+1,$ - line after current line to end
  • .,.+4 - current to current+5 line, inclusive
  • ?a?,/b/ - between patterns a and b, inclusive

flags

Substitution flags can be:

  • c - to confirm each substitution
  • g - to replace all occurrences in the line
  • i - ignore case for the pattern
  • I - don’t ignore case for the pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment