Loading ...
Sorry, an error occurred while loading the content.

Simple Automatic Folding

Expand Messages
  • 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
    Message 1 of 1 , Jul 30, 2005
    • 0 Attachment
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.