On Wed 18-Oct-06 10:24pm -0600, A.J.Mechelynck wrote:

> Peng Yu wrote:
>> Hi,
>> 
>> I have the following file segments. I want to concatenate all the
>> lines with their next lines, except that it ends with "}}". I want to
>> use the pattern "\(}}\)[EMAIL PROTECTED]". It seems not working.
>> 
>> Would you please help me to figure out how to match the lineend without 
>> "}}"?
>> 
>> Thanks,
>> Peng
>
> To join every line not ending in }} with the following line, use the ":j[oin]"
> command on every line _not_ matching the pattern /}}$/ which means "two
> closing braces at end of line". As a cherry on the cake, you can avoid joining
> the last line in the file (which has no following line):
>
>         :1,$-1v/}}$/j
>
> See
>         :help multi-repeat
>         :help :join

Let's assume those 10 lines in the example were the only
lines in the buffer.

vglobal will first mark lines 1-3 and 5-9.  It will next
apply the join command to each of those lines.  The line
numbers below refer to these original line numbers.

The join on 1 will join lines 1&2, the no longer existing
line 2 is skipped, join lines 3&4, join lines 5&6, skip 6,
join 7&8, skip 8 and, finally, join 9&10.

You end up with 5 lines.  The goal is to end with 2 lines.

-- 
Best regards,
Bill

Reply via email to