On Feb 18, 10:55 am, Maxim Kim <[email protected]> wrote:
> Hi
> Is it possible to make syntax folding could fold the following text:
>
> ! Level 1
> blablabla
> blablabla
>
> !! Level 2
> blablabla
> blablabla
> blablabla
>
> !!! Level 3
> blablabla
> blablabla
> blablabla
>
> !!! Level 3
> blablabla
> blablabla
> blablabla
>
> !! Level 2
> blablabla
> blablabla
> blablabla
>
> ! Level 1
> blablabla
> blablabla
> blablabla
>
> into:
> +-- 23 lines: ! Level 1----------
>
> +-- 4 lines: ! Level 1----------
>
> With all levels folded according to count of exclamation marks.
>
> For level1 folding I have the next command:
> :syntax region level1 start=/^![^!]\+.*/ end=/\n\+\ze![^!]\+.*/
> transparent fold
>
> For level2 folding the similar command doesn't work (region should
> start at double ! and end at double or single !):
> :syntax region level2 start=/^!![^!]\+.*/ end=/\n\+\ze!!\?[^!]\+.*/
> transparent fold
>
> Why the last command does wrong folding?

You need to give level 2 the 'contained' attribute, and indicate that
level 1 can contain level 2: e.g.,

:syntax region level1 start=/^![^!]\+.*/ end=/\n\+\ze![^!]\+.*/
transparent fold contains=level2
:syntax region level2 start=/^!![^!]\+.*/ end=/\n\+\ze!!\?[^!]\+.*/
transparent fold contained

:help syn-contained

Brett S.


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to