sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

SimpylFold : No-BS Python code folding

 script karma  Rating 35/16, Downloaded by 1011    Comments, bugs, improvements  Vim wiki

created by
Taylor Hedberg
script type
Because of its reliance on significant whitespace rather than explicit block delimiters, properly folding Python code can be tricky. The Python syntax definition that comes bundled with Vim doesn't contain any fold directives at all, and the simplest workaround is to `:set foldmethod=indent`, which usually ends up folding a lot more than you really want it to.

There's no shortage of Vim plugins for improved Python folding, but most seem to suffer from cobbled-together algorithms with bizarre, intractable bugs in the corner cases. SimpylFold aims to be exactly what its name suggests: simple, correct folding for Python. It's nothing more than it needs to be: it properly folds class and function/method definitions, and leaves your loops and conditional blocks untouched. There's no BS involved: no screwing around with unrelated options (which several of the other plugins do), no choice of algorithms to scratch your head over (because there's only one that's correct); it just works, simply.
install details
If you use Pathogen and Git to manage your Vim plugins (highly recommended), just clone my Github repo (see https://github.com/tmhedberg/SimpylFold) into your ~/.vim/bundle directory as a submodule. Otherwise, unzip the archive and drop the contained directories into your ~/.vim directory.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
SimpylFold.zip 1.1 2012-03-09 7.0 Taylor Hedberg     - Performance improvements (up to 3-4x faster in large buffers)
    - Option to display first line of folded docstring in fold text
    - Help file
    - Numerous bug fixes
    - BSD license
SimpylFold.vim 1.0.2 2011-12-18 7.0 Taylor Hedberg Fixed infinite loop bug trigged when the first line of the buffer is indented.
SimpylFold.vim 1.0.1 2011-10-08 7.0 Taylor Hedberg Old version was uploaded incorrectly.

Also fixed folding of functions and classes with mutli-line signatures.
SimpylFold.vim 1.0 2011-09-03 7.0 Taylor Hedberg Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo