Persistent folds between Vim sessions
Folds are great. They help you when you have to deal with big files where compartmentalizing the logic might be of help.
The problem is that when you close Vim, your artfully folded code returns to its unfolded state.
The solution is quite simple - when you are ready to save your folds run the
:mkview command. This will save your folds in the current buffer to your viewdir (
:h viewdir) depending on your environment.
To load your folds use
To automate this process add the following to your vimrc:
augroup AutoSaveFolds autocmd! autocmd BufWinLeave * mkview autocmd BufWinEnter * silent loadview augroup END
The folds will be local to your machine, but if you want you can configure
mkview to save folds to a file in your project directory and share them with your team.