On 2016-01-04, Hongbo Liu wrote:
> The vim document says that foldexpression is very slow. The cpp file is in our
> corporation's repository, it's inconvenient to modify the file.
I'm in the same situation. I've been using
setlocal foldmethod=marker
setlocal foldmarker={,}
to have convenient folding of C blocks. Every now and then the
folding would become corrupted by an initialization such as your
static long days[13] = {30, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
;
It was a minor annoyance so I hadn't looked for the reason.
As a result of this discussion, I'm now using the following for C
folding instead.
setlocal foldmethod=expr
setlocal foldexpr=CFoldExpr(v:lnum)
function! CFoldExpr(lnum)
let l:list = split(getline(a:lnum), '\zs')
let l:count = count(l:list, '{') - count(l:list, '}')
if l:count == 0
return '='
elseif l:count > 0
return 'a'.l:count
else
return 's'.-l:count
endif
endfunction
I haven't experienced any speed issues so far.
Regards,
Gary
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.