views:

148

answers:

4

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?

+20  A: 

d126G

Delete, line number, go.

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

Brian Rasmussen
+1'ing this as it requires fewer characters (and at least to me, fits far more into the "language of vim") than the other options.
Amber
I like this because you don't have to use the : command, which seems relatively clumsier.
Phenom
Exvept that you can log your ':' commands to some file (viminfo), and it can be later reused. I do love 'q:' then '/searchforsomething' then hit enter...
Zsolt Botykai
+3  A: 
:,126d

all done.

Peter
+1  A: 

Use this command:
65,126d

Neeraj
This will delete lines from 65 to 126, but author wants to delete only line #126
Vestel
Nope, the author wrote "delete up to".
Zsolt Botykai
@Vestel,In that case none of the above answers are doing that:P
Neeraj
Actually they do.
Phenom
+3  A: 
:.,126d

. is the actual line. If you want delete from the next line, you can use .+1 instead.

Zsolt Botykai
+1 because that's how I do it ;-)
ammoQ