Gene Kwiecinski wrote:
> This is bugging me, because I'm *sure* I did something like this before,
> only now I'm misremembering something.
>
> I'll use html as an example...
>
> If I wanted to delete text between certain tags (actually, *any*
> start/end text), in multiple instances scattered throughout a huge file,
> I was able to do something along the lines of
>
> :g/<h1>/.,/<.h1>/s/.*/<h1><\.h1>/p
Well, you don't need/want the backslash before the dot, but I doubt that
causes problems. But I'm not sure this does what you want anyway, since
it means replace the entirely of every line from lines containing <h1>
to following lines containing <.h1>. I.e. it won't work if the <h1> and
</h1> are on the same line, or if there is text preceding or following
the tags on those lines, and it will change every line in the range, not
replace the range with a single line. I think it's more likely you just
want a multi-line substitute:
:%s/<h1>\_.\{-}<.h1>/<h1><\/h1>/g
The \_. is like . but matches newlines, too, and the \{-} is a
non-greedy * so it matches between the <h1> and the *next* <.h1> rather
than matching to the final <.h1> in the file.
Better?
Ben.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---