Simple Automatic Folding

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Simple Automatic Folding

Joshua J Estelle
Hi all,

I'm new the mailing list and am hoping I can get a question answered
about folding.

I recently discovered folding in vim and I love it, but I've noticed as
my files grow larger, with more and more folds editing becomes
painfully slow as vim is constantly redefining folds.

I have my folding defined with the following commands in my .vimrc:

autocmd FileType java syn region myFold start="{" end="}" transparent
fold
autocmd FileType java syn sync fromstart
autocmd FileType java set foldmethod=syntax
autocmd FileType java set foldlevel=1

(at least for Java files, and similarly I have it defined for perl
files)


When working with smaller files this works great.  Every block of {  }
becomes a fold and I can open and close them and all is good.

But when my files start getting bigger, with more and more folds, it
becomes increasingly difficult to edit.  As whenever I type a {, it
pause a long time as it seems to redefine all the folds later in the
document.  Similarly when I type } it redefines them all again.

As a work around I've gotten into the habit of keeping
{
}
in one of my copy-paste buffers, so I can paste them at once and they
don't disturb my other folds and just become a new one, but it'd be
nice if I didn't have to work that way.

So I'm wondering what I'm doing wrong?  Or if there's a better way to
do this?
Or is there a way I can have it only redefine the folds when I say
so... and not automatically every time I type a { or }.

Thanks so much.

Much appreciation,
Josh