vim Command-line ranges Line shortcuts


Example

  • . represents the current line but it can also be omitted entirely.
  • $ represents the last line.
  • % represents the whole buffer, it is a shortcut for 1,$.

The two commands below execute :command on every file from the current line to the last line:

:.,$command
:,$command

The command below executes :command on the whole buffer:

:%command