Vim: Ranges Cheat Sheet

A range permits a command to be applied to a group of lines in the current buffer. For most commands, the default range is the current line.

  • :21s/old/new/g – Line 21
  • :1s/old/new/g – First line
  • :$s/old/new/g – Last line
  • :%s/old/new/g – All lines
  • :.,$s/old/new/g – Current line to end

Leave a Reply

Your email address will not be published. Required fields are marked *