Noah Spurrier wrote:
I used this pattern to select sections of test that belong to me
when CVS or SVN generates a merge conflict. This pattern works fine:
/^<<<<<<<\_.\{-}=======.*$/
[cut]
:g/^<<<<<<<\_.\{-}=======.*$/d
Again, this would only delete the first line of the pattern match.
Since you know that the two pieces will not fall on the same
lines, you can do something like
:g/^<<<<<<<<</.,/^=========/d
That's the same :g/pattern/command where the "command" portion in
this case is ".,/^======/d" which translates to "from the current
line (found by the "g" in this pass) through the next line that
matches the pattern /^==========/ delete those lines".
Things would get a little trickier if you would have had the
possibility of lines that actually matched something like:
<<<<<<<<<<=======
where the starting and ending delimiters were on the same line.
The above :g solution I gave would give waaay wrong results. :)
It can be mostly remedied with
:g/^<<<</.,-/^=====/d
(adding the minus sign to begin the search for the "===" back one
line), but it still has some disappointing edge cases: the first
line of the file, and lines of the form "=======<<<<<<<" where
the equals come before the less-thans. Pathological, I know, but
better to have you forearmed before getting nicked by them.
Another possibility might be something like this untested
:%s/\_$\_s<<<<<<<\_.\{-}=====$//
which is likely the closest to what you're looking for. (I may be
off by the number of whitespace characters one has to eat at the
beginning of things)
A couple ideas to try,
-tim