Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting up to a certain line in Vim

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?

like image 788
neuromancer Avatar asked Feb 12 '10 08:02

neuromancer


People also ask

How do I delete a specific line in Vim?

Deleting a single line in Vim editor: First, bring your cursor to the line you want to delete. Press the “Esc” key to change the mode. Now type, “:d”, and press “Enter” to delete the line or quickly press “dd”.

How do I go to a specific line number in Vim?

The Vim goto line number command One can use the G letter. For example, press [ESC] key and type 10G (Shift-g) goto line number 10.

How do I delete a chunk of text in Vim?

Step 1: Move your cursor to the top line of the block of text/code to remove. Step 2: Press V (Shift + v) to enter the Visual mode in Vim/Vi. Step 3: Now move your cursor down to the bottom of the block of text/code to remove. Step 4: Press d to delete the block selected.


1 Answers

d126G

Delete, line number, go.

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

like image 123
Brian Rasmussen Avatar answered Oct 11 '22 11:10

Brian Rasmussen