On Jul 29, 8:53 am, <[email protected]> wrote:
> Hi,
>
> I have a file with many procedures like this:
>
> CREATE PROCEDURE MyProcedure1
> AS
> ...<body>...
> GO
>
> CREATE PROCEDURE MyProcedure2
> AS
> ...<body>...
> GO
>
> ...
>
> In some of the procedure bodys, there is the word COLLATE.
> For these procedures I d like to write the header line (CREATE PROCEDURE..)
> into a file.
>
> How can vim do this?
>

g/COLLATE/?^CREATE PROCEDURE?w! >> filename

This uses a g/COLLATE command to, for every line it sees COLLATE, find
the line nearest line above starting with CREATE PROCEDURE and append
it to a file.

:help :g
:help :range
:help :write_a

Note that I tested with :print instead of :w! >> filename
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to