Folding in vim

Terry Hancock hancock at
Sun Jul 3 05:35:52 CEST 2005

My general attitude towards IDEs and editors has been 
extremely conservative, but today I decided to see what 
this "folding" business was all about.

I see that vim (and gvim, which is what I actually use)
has this feature, and it is fairly nice, but at present it's
very manual --- and frankly it's hard for me to see the
point if I have to manually mark folds every time I start

I tried to load a couple of different scripts to 
automatically fold Python code in vim, but none of them
seems to do a good job.

The obvious thing (to me) would be for functions and
classes to be folded at the top level, with each method
folded inside the class folds.  But I can't seem to figure 
out how to make that happen (other than manually,
I mean).  Actually, I usually want to fold the comment
block at the top with the license disclaimer and module
documentation, too, but I can do that manually.

I've tried:
python_fold.vim by Jorrit Wiersma
AutoFold.vim by Dave Vehrs

Does anybody have a better suggestion (or perhaps can
tell me how to make one of these do what I'm wanting)?

I'm assuming that I can set these by using the 
Tools -> Folding -> Fold Method -> Syntax
 (or Expression for python_fold)

but it doesn't seem to work. python_fold seems to just
collapse methods (but not the whole classes they are in),
and I can't seem to make AutoFold do anything at all, so
I must be using it wrong.

Terry Hancock ( hancock at )
Anansi Spaceworks

More information about the Python-list mailing list