Vim Python-Mode Folding
Asked Answered
M

3

17

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.

Modlin answered 10/5, 2014 at 8:55 Comment(0)
T
36

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.

Trilogy answered 10/5, 2014 at 8:59 Comment(0)
B
5

You close a fold in vim by pressing zc. To close all folds: zM. This is all in the Vim docs.

Buford answered 10/5, 2014 at 8:57 Comment(1)
Thank you. I was looking in the wrong place then. zc and zo.Modlin
E
3

Haivng set foldclose=all in your vimrc will solve it. More details at :h fcl.

This automatically folds when the cursor is not in the fold. Hence, advantageous by not requiring refold by manual typing of commands like zc.

You can find list of fold related commands at help fold-commands, if you don't want foldclose option

Edmondedmonda answered 26/1, 2016 at 21:1 Comment(1)
It may also be useful to know that set nofoldenable makes sure that when opening, files are "normal", i.e. not folded.Pigmentation

© 2022 - 2024 — McMap. All rights reserved.