>
> I tested against this text:
>
> ======= text starts here =======
> [
> l1
> l2
> l3
> ]
> [
> l4
> l5
> ]
>
> l1
> l2
> l3
> l4
>
> l1
> l2
> l3
> l4
> l5
>
>
>
> ====== text ends here ========
>
> The following command finds four matches on the previous text:
>
> :%s/\(\[\_p\{-}]\)\|\(\%^\|^\n\)\@<=\(\p\+\n\)\{-1,}\ze\(^\n\|\%$\)//n
>
> Explanation:
>
> :%s
> / start pattern
> \( start group
> \[ literal [
> \_p any printable + \n
> \{-} 0 or more, as few as posible
> \] literal ]
> \) end group
> \| or
> \( start group
> \%^ start of file
> \| or
> ^\n an empty line
> \) end group
> \@<= match starts after previous group
> \( start group
> \p\+\n a non-empty line
> \) end group
> \{-1,} 1 or more, as few as posible
> \ze match ends before the next group
> \( start group
> ^\n empty line
> \| or
> \%$ end of file
> \) end group
> //n
>
> It was fun writing that, but I suppose that somebody else can find a shorter
> alternative.
>
> Cheers!
> Israel
Your answer is most enlightening. Thank you for taking the time to
respond in such detail!
Yosi
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php