Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alienlebarge/8deec0f7edf3010f6966865dcac888a2 to your computer and use it in GitHub Desktop.
Save alienlebarge/8deec0f7edf3010f6966865dcac888a2 to your computer and use it in GitHub Desktop.

How to define a range

line 28

:28s/bad/good/g

first line

:1s/bad/good/g

last line

:$s/bad/good/g

all lines in a file (same as 1,$)

:%s/bad/good/g

lines 6 to 28 inclusive

:6,28s/bad/good/g

lines 11 to end of the file

:11,$s/bad/good/g

current line to end of the file

:.,$s/bad/good/g

line after current line to end

:.+1,$s/bad/good/g

current to current+5 line, inclusive)

:.,.+4s/bad/good/g

between patterns a and b, inclusive)

:?a?,/b/s/bad/good
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment