:[range] s[ubstitute]/pattern/string/[flags] [count]
Everything enclosed between []
in this command is optional.
Range can be:
28
- line 281
- first line$
- last line%
- all lines in a file (same as1,$
)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 patternsa
andb
, inclusive
Substitution flags can be:
c
- to confirm each substitutiong
- to replace all occurrences in the linei
- ignore case for the patternI
- don’t ignore case for the pattern