Vim tip 25: substitute flags
Here are some of the flags you can use with the substitute command:
greplace all occurrences within a matching line- by default, only the first matching portion will be replaced
cask for confirmation before each replacementiignore case for searchpatternIdon't ignore case for searchpattern
These flags are applicable for the substitute command but not / or ? searches. Flags can also be combined, for example:
s/cat/Dog/gireplace every occurrence ofcatwithDog- Case is ignored, so
Cat,cAt,CAT, etc are all valid matches - Note that
idoesn't affect the case of the replacement string
- Case is ignored, so
See :h s_flags for a complete list of flags and more details about them.
Video demo:
See also my Vim Reference Guide and curated list of resources for Vim.