Vim Python-Mode Folding

Eric Miller picture Eric Miller · May 10, 2014 · Viewed 9.3k times · Source

I recently downloaded Python-Mode. When I open a python script, my functions are folded. I can unfold easily (it's one of the movement keys when you're on top the function definition). However, I can't figure out how to re-fold the function.

Moreover, and perhaps most importantly, :help pymode returns an error ('E149: Sorry, no help for pymode'). So I can't even look up the documentation.

Any help would be appreciated.

Answer

pfnuesel picture pfnuesel · May 10, 2014

Here a list of folding commands:

zf#j creates a fold from the cursor down # lines.
zf/string creates a fold from the cursor to string .
zj moves the cursor to the next fold.
zk moves the cursor to the previous fold.
zo opens a fold at the cursor.
zO opens all folds at the cursor.
zc close a fold at the cursor.
zm increases the foldlevel by one.
zM closes all open folds.
zr decreases the foldlevel by one.
zR decreases the foldlevel to zero -- all folds will be open.
zd deletes the fold at the cursor.
zE deletes all folds.
[z move to start of open fold.
]z move to end of open fold.

What you are looking for is zc.