On 4/17/06, Daniel Nogradi <[EMAIL PROTECTED]> wrote:
> I came across a strange problem, strange at least to me. I'm using vim
> 6.3 on a linux box.
>
> The thing has to do with folding. If I type
>
> :setlocal foldmethod=expr
> :setlocal foldexpr=0
>
> then the foldlevel of every line should be zero. This I do just to
> make sure that the starting point is clear. After the above I do a
>
> :syn region myFold start='{' end='}' transparent fold
> :syntax sync fromstart
> :setlocal foldmethod=syntax
>
> in order to have everything folded between { and } as is useful for C
> coding. Now the strangeness is that this most of the time work,
> however if I'm jumping back and forth between different files in
> different windows (I use vim in a single xterm but have several :split
> and :vsplit windows) using tags then sometimes it breaks down and the
> whole file gets folded at the first function, that is after the first
> { everything is folded together although there are several other
> functions in the file with several { } pairs.
>
> What is not clear to me is that even if this happens then if I type
> all the commands above that should fix it, since with the first 2
> commands all folding related thing should be erased, shouldn't it?
Your ':syntax' commands are not reset when you just retype them.
To reset your syntax commands, you need to add something
like this at the beginning of your sequence of commands:
:syn clear | syn on
or
:syn off | syn on
The 2nd point: I'm not sure if your 'syn region' accounts properly
for '{' inside comments/strings. Is it possible that '{' inside
comments or strings confuses it ? I'm not sure.
Yakov