Consider the text:

{{{1

}}} {{{1

}}}

With :set fdm=marker foldcolumn=4, we get:

-   {{{1
|
-   }}} {{{1
|
|   }}}

This is fairly intuitive. For this ismple example, I would expect this
to work in the same way (intuitively, not necessarily because of the
documentation, which is vague on what is supposed to happen in this
case):

:syntax region afold start='{{{' end='}}}' fold
:set fdm=syntax foldcolumn=4

But instead we get:

-   {{{1
|
|   }}} {{{1
|
|   }}}

This means (among other things) that it would be very difficult to
achieve this with syntax folding:

-   if (avar) {
|     afunc();
-   } else {
|-    if (bvar) {
||      bfunc();
|-    } else {
||      cfunc();
|     }
|   }


Now consider:

{{{

}}} {{{

}}}

With fdm=syntax, we again get:

-   {{{
|
|   }}} {{{
|
|   }}}

This is at least consistent, but still presents the same problem.

On the other hand, fdm=marker gives:

-   {{{
|
|-  }}} {{{
|
|   }}}

This difference is fairly confusing. In addition, note that the level
2 fold actually folds no lines. This is even more confusing. This may
be a bug.

Syntax folding is not a bug, but it seems to be poorly-defined
behavior. And there is definitely room for improvement (at least in
the documentation, though preferably in the implementation).

I think I understand the behavior of syntax folding. The foldlevel
increases by 1 for the line where the region starts, and ends at the
exact place the region ends, decreasing the fold level back to zero.
This allows the next region to also increase the fold level by 1.
However, since a line cannot simultaneously be in two un-nested folds,
the entire area looks like it is in a single fold with foldlevel 1.

I'd really like to see the ability to have syntax folding act like
marker folding in the first example. Other editors (such as Ultraedit,
the program _most_ of my team at work uses) can handle syntax folding
of C code perfectly fine regardless of the coding style. I was very
disappointed to discover that Vim cannot, at least without some fairly
nasty logic in the c.vim syntax file to handle each case.

So, feature request: perhaps this could be implemented with another
argument to the :syntax region/match commands, like this:

:syntax region afold start='{{{' end='}}}' fold foverlap=break
would give
-   {{{
|
-   }}} {{{
|
|   }}}

:syntax region afold start='{{{' end='}}}' fold foverlap=nest
would give
-   {{{
|
|-  }}} {{{
||
||  }}}

:syntax region afold start='{{{' end='}}}' fold foverlap=continue
would give the current result,
-   {{{
|
|   }}} {{{
|
|   }}}

This last one could be made the default for backwards compatibility. I
imagine, however, that "break" is the normally desired option.

Or, it could be a window-local option instead, but I think the
argument to the syntax definitions is better.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui