On Thu, Oct 22, 2009 at 10:14 AM, Tim Chase <[email protected]> wrote:
>
>> What I want to do is to find every line starting with 'delete' and
>> delete from the 'aaaa' line till the 'bbbb' line.
>>
>> I thought about using a global command to do that, but I can't get it
>> working.
>
> You're on the right track.  Assuming your bracketing lines always
> exist in parity around your lines-to-delete, you can do something
> like
>
>   :g/^delete/?aaaa?,/bbbb/d
>
> which roughly translates to
>
>   /^delete/  on lines matching "^delete"
>   ?aaaa?     go backwards to find "aaaa"
>   ,          through
>   /bbbb/     going forward from "aaaa" to the line with "bbbb"
>   d          delete this range ("aaaa" through "bbbb")
>
> Odd edge cases occur if they can be arbitrarily nested, if the
> start/end (aaaa/bbbb) lines don't always occur, or if your
> aaaa/bbbb patterns happen to contain "^delete".  But for the
> general case, the above should do the trick.
>

Very clever. I began wondering why not simply ":g/aaaa/;.,/bbbb/d",
then I read your explanation more carefully and went back and read the
OP again (this time completely).

-- 
HTH,
Hari

> -tim
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to