Here are some of the flags you can use with the substitute command:

  • g replace all occurrences within a matching line
    • by default, only the first matching portion will be replaced
  • c ask for confirmation before each replacement
  • i ignore case for searchpattern
  • I don'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/gi replace every occurrence of cat with Dog
    • Case is ignored, so Cat, cAt, CAT, etc are all valid matches
    • Note that i doesn't affect the case of the replacement string

info See :h s_flags for a complete list of flags and more details about them.

Video demo:


info See also my Vim Reference Guide and curated list of resources for Vim.