On Mon, Jul 24, 2006 at 12:30:07PM -0500, Thore B. Karlsen wrote:

> I use foldmethod=expr with the following foldexpr:
> 
> set foldexpr=GetFoldLevel(v:lnum) 
> 
> function! GetFoldLevel(line) 
>    let line_text = getline(a:line) 
>    if (line_text =~ '\%({.*}\)\|\%(}.*{\)')
>       return '=' 
>    elseif (line_text =~ '{') 
>       return "a1" 
>    elseif (line_text =~ '}') 
>       return "s1" 
>    endif 
>    return '=' 
> endfunction 
> 

I haven't read the above too carefully: But if all you want to do is
fold your code based on {...} blocks, then use Vim 7 and set fdm=syntax
(for C / C++ files).

Incidentally, fdm=syntax is also slow (though much much faster than
fdm=expr). I could (grudgingly) live with a short delay when first
loading the file. The thing that bothers me is that when I switch
between buffers, Vim takes it's own sweet time to get the syntax based
folding right.

So I only enable syntax folding for files that have less than 3000
lines. Once my clever spies steal Benji Fisher's computer, I'm going to
up this limit to 18000.

GI

-- 
You're not drunk if you can lie on the floor without holding on.

Reply via email to