Thursday, April 19, 2012

Delete including newlines

I have some text like this:

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

I want to delete a range like this:

:g/^# Start of the range\n#.*\n#.*/norm 3dd

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?

--

.

--
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

No comments: