What is the recommended way to use Vim folding for Python code What is the recommended way to use Vim folding for Python code python python

What is the recommended way to use Vim folding for Python code


Personally I can't convince myself to litter my code with the markers. I've become pretty used to (and efficient) at using indent-folding. Together with my mapping of space bar (see below) to open/close folds and the zR and zM commands, I'm right at home. Perfect for Python!

set foldmethod=indentnnoremap <space> zavnoremap <space> zf


I use this syntax file for Python. It sets the folding method to syntax and folds all classes and functions, but nothing else.


Yet another plugin for folding Python code. Rather simple, handling docstrings, and on the GitHub:

SimpylFold

Enjoy!