Deleting up to a certain line in Vim

neuromancer picture neuromancer · Feb 12, 2010 · Viewed 27.6k times · Source

I know that to delete n lines, the command is [n]dd, where n is the number of lines to delete.

But what if I want to delete up to a certain line number? Say, if I'm on line 65 and I want to delete up to line 126 without having to do the math, how could I do that?

Answer

Brian Rasmussen picture Brian Rasmussen · Feb 12, 2010

d126G

Delete, line number, go.

A lot of commands in Vim can be followed by a move command to specify the scope.