Just adding one more to make it complete to the point of discussion.
To enable code folding:
:set foldenable
or in short, :set fen
To disable code folding:
:set nofoldenable
or in short, :set nofen
Once you enable codefolding, you will have all the commands like zf,zo etc
at your wish according to the setting of :set fdm=xxxx
where typical values are expr,syntax,manual etc.
Vim makes it amazingly hard to disable folding, especially when using vimdiff.
None of the above posted solutions worked for me, but this did (add to ~/.vimrc):
au WinEnter * set nofen
au WinLeave * set nofen
I set foldlevel=20
, foldlevelstart=20
and I use foldmethod=syntax
.
It's help me work with correct folding in vim.
set nofoldenable
disable folding but sometimes I need it
vim.wikia