Setting in your .vimrc
:
" Fold by syntax because there are indent is not always correct
set foldmethod=syntax
" Beware, there are lot of instructions tell you use `set nofoldenable` to avoid folding at start
" but then when you start using `z c`, it will start the fold method and automatic fold ALL the code.
" Using this with `foldlevel` give the same effect but does not have that problem.
set foldenable
set foldlevel=20 " Bigger than 20 does not work
Using:
z c
to fold.z o
to open it.
How to remember:
- Imagine
z
is a folded paper :) c
is close.o
is open.- Enjoy vim.
Read more: https://vim.fandom.com/wiki/Folding