How to enable and use code folding in Vim

vim

How can I enable and do code folding in Vim?

Do I have to change anything in ~/.vimrc?

I type z+a and z+c and z+o and nothing happens.

Here is an article about folding: Code folding in Vim.

Best Answer

No you don't have to put the command from the page you linked to in your ~/.vimrc, you can just type them after issuing : in vim to get the command prompt.

However if you put the lines:

set foldmethod=indent   
set foldnestmax=10
set nofoldenable
set foldlevel=2

as indicated in the link you gave, in your ~/.vimrc, you don't have to type them every time you want to use folding in a file. The set nofoldenable makes sure that when opening, files are "normal", i.e. not folded.

Related Question