On 04/19/12 10:57, Paul wrote:
I have some text like this:

# Something important
# Start of the range
# anything could be here
# anything could be here
# Something important

That is: the start of the range, followed by the next two lines but only if 
they're also comments (I'm going to automate it, so I must make sure that those 
lines are such).

:g/^# Start of the range\n#.*\n#.*/d

doesn't work, because it deletes only the first line. Is my 'norm 3dd' method 
the best way?

I'd usually use

 :g/^# Start of the range\n#.*\n#/.,+2d

which does as you describe. Alternatively, if you can identify the 2nd "Something important", you can do things like

 :g/^# Start of the range/.,/^# Something important/-1d

which will delete from "Start of the range" through the line before ("-1") the next line matching "^# Something important".

All sorts of nifty Ex tricks here.

-tim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to