vimreplace

Vim Search/Replace, meaning of %s


In Vim you can search/replace text in the following way.

:%s/old/new

What does the %s mean?


Solution

  • % is the range over which the :s command (short for :substitute) will be run. % itself is short for the range :1,$, which means Line 1 to the last line in the buffer.

    The Vim help has a couple topics (user manual - :help 10.3, reference manual - :help cmdline-ranges) describing the forms that ranges can take.