Hi Thore,
You can probably get away with foldmethod=expr in large files by de-activating
it in Insert mode. I.e., add this to your after/ftplugin/php.vim:
augroup FastFold
autocmd!
autocmd InsertEnter * if &ft == 'php' | setlocal foldmethod=manual | endif
autocmd Insertleave * if &ft == 'php' | setlocal foldmethod=expr | endif
augroup end
I tried it out and it actually seems to work. Folds are re-evaluated when you
are finished inserting.
HTH,
Peter
--- "Thore B. Karlsen" <[EMAIL PROTECTED]> wrote:
> On Mon, 24 Jul 2006 23:48:12 -0500, Thore B. Karlsen <[EMAIL PROTECTED]>
> wrote:
>
> >>Hi Thore,
> >>
> >>I've never tried folding like this before, and unfortunately I don't have
> time
> >>to try out this 'optimized' version, but it may work faster for you (I've
> just
> >>replaced the regex matches with stridx and rearranged the code flow):
> >>
> >> set foldexpr=GetFoldLevel()
> >>
> >> function! GetFoldLevel()
> >> let line_text = getline(v:lnum)
> >>
> >> let left_idx = (stridx(line_text, '{') >= 0)
> >> let right_idx = (stridx(line_text, '}') >= 0)
> >>
> >> if left_idx
> >> if ! right_idx
> >> return 'a1'
> >> endif
> >> elseif right_idx
> >> return 's1'
> >> endif
> >>
> >> return '='
> >> endfunction
>
> >Thanks! I did a quick test, and that does appear to speed it up. One
> >of the files that was giving me problems before is now fast enough to
> >work in. There's still a slight latency when I type, but it's much
> >better. I'll do some more testing to see how it works in other files,
> >but this looks promising!
>
> I spoke too soon. I tested it on another file that is 2500 lines long,
> and it is still unbearably slow. It gets worse towards the end of the
> file, where it can still take seconds for characters to show up when I
> type them. I think I'll have to fire up vim in a profiler to see what
> is causing this slowness, because if this system can compress dozens
> of channels of video in realtime without breaking a sweat it seems
> strange that inserting a character in a smallish text file would be a
> problem.
>
> --
> Be seeing you.
>
>
Send instant messages to your online friends http://au.messenger.yahoo.com