Saturday, February 5, 2011

Re: Delete lines matching hits

On 02/05/2011 05:02 PM, Ben Fritz wrote:
>>> I wonder if there's a way to do the same but instead of copying them
>>> to the clipboard, delete them.
>>
>> :g/pattern/d
>
> I think this will not work for the second part claimed by the comment
> in the code posted: "The pattern may extend over multiple lines."
>
> For example,
>
> abc
> def
> ghi
>
> :g/abcc\ndef/d
>
> will delete only "abc", it will not delete "def".
>
> I'm not sure how important this is to the OP...

If it is, it should be fairly possible to do it with a :s
command, something like

:%s/^abc\ndef\n//

-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

No comments: