I’ve been pushing off learning code folding in vim for a few weeks now. I ended that procrastination and I present to you a short tutorial on code folding in vim.
The import things to remember here are to get your settings correct:
"folding settings set foldmethod=indent "fold based on indent set foldnestmax=10 "deepest fold is 10 levels set nofoldenable "dont fold by default set foldlevel=1 "this is just what i use
Then you can toggle folding with za. You can fold everything with zM and unfold everything with zR. zm and zr can be used to get those folds just right. Always remember the almighty help file at “help :folding” if you get stuck.