Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: globally match line, delete this and 2 following lines

Tags:

vim

The following is what I have in mind:

% g/All Claims\t 0/3d

This doesn't work, though (it seems to be invalid syntax to multiply an action in this mode). I did end up with the following sequence:

qq
/All Claims\t 0
3dd
q
10000@q

That macro combination worked out just fine. I'm simply curious if there's something that would have been an appropriate and would have fit in the context of the first example. To further expand, I'm seeking something that replaces the 3d from the first line with a command that will do the same, or will appropriately reference a macro.

like image 506
Jeff Ferland Avatar asked Apr 22 '10 14:04

Jeff Ferland


1 Answers

The :g command expects an ex command, so you have to use :normal like this

:%g/All Claims\t 0/norm 3dd
like image 126
Matteo Riva Avatar answered Oct 10 '22 18:10

Matteo Riva