I often use a manual folding method, which is
: Set Foldmethod=manual
The commonly used folding commands for VIM are:
ZF: Collapse the selected row
Zo: Open collapse
ZR: Open All folds
ZM: Close all folds
ZD: Delete collapsed
My personal most commonly used folding method is to first move the cursor to an opening parenthesis or a closing parenthesis, and then use zf% to collapse a piece of code
There is a common problem: you open a file, do a lot of folding and then close the file, and then open it again after the collapsed information is gone.
Before closing, use: Mkview Save the current view, the next time you open the file with: Loadview You can restore the previous folding record.
But every time to do it manually: Mkview and: Loadview is still a cumbersome operation, you can configure the following in. VIMRC:
au BufWinLeave * silent mkviewau BufWinEnter * silent loadview
This is done automatically every time the file is closed: Mkview, and each time the file is opened, it will be executed automatically: Loadview.
Vim How to save collapsed information