Create Folding
- select with 'v', 'zf'
- 'zf3j', fold the current line and the 3 following lines
- 'zfa}', fold a code block using curly braces ({...})
- select with 'va}', then 'zf', fold a code block
Open and Close Folding
- 'zc', close folding
- 'zo', open folding
- 'za', toggle close/open folding
Remove Folding
Save Folding
- Manual
- Create a .vim folder under home directory (~)
- Create foldings in a file
- ':mkview' and close the file, save foldings
- Open the file and ':loadview', load the foldings
- Auto
# add to .vimrc under home directory
augroup remember_folds
autocmd!
au BufWinLeave ?* mkview 1
au BufWinEnter ?* silent! loadview 1
augroup END