VIM Code Folding
Vim code folding can be set with the "foldmethod" option, such as: Set Foldmethod=indent
There are 6 ways to collapse code
1. manual//Manual definition Folding
2. Indent//Folding with indentation
3. Expr//definition of folding with expression
4. Syntax///Use syntax highlighting to define folding
5. diff//Folding text without changes
6. Marker//Folding with logo
The VIM profile is divided into global configuration files and user profiles
1. Global configuration file Lookup, in. Vim input: Echo $VIM, generally:/USR/SHARE/VIM/VIMRC
2. User profile in the user's home directory, such as:/HOME/FUKUN/.VIMRC
To set the folding mode in the VIMRC file: such as: Set Foldmethod=marker
When you select the Fold method, you can use the collapse command to collapse the operation. The usual folding methods are indent and marker.
Indent is the most fool folding method, according to the indentation, as long as your code to maintain a good writing specifications, in the function name of the line directly press the ZA can be folded.
Recommend everyone to use: Marker folding command
Because it's more general, it's easy to transplant. When people look at your code, they can understand it directly.
Marker folding Mode, we need to use the meter to identify the collapse of the code, the system defaults to {{{and}}}
Collapse command
ZF creates folds, such as in marker mode:
zf56g, create a code fold from the current line up to 56 lines;
10zf or 10zf+ or zf10↓, create code folding from the current line to the following 10 lines.
10zf-or zf10↑ to create a code collapse from the current line up to the previous 10 lines.
In parentheses, create a zf% from the current line to the corresponding match ((),{},[],<>, etc.).
ZD Deletes (delete) The collapse under the cursor. Valid only if ' Foldmethod ' is set to ' manual ' or ' marker '.
ZD the collapse of a circular delete (delete) cursor, that is, a nested delete collapse. Valid only if ' Foldmethod ' is set to ' manual ' or ' marker '.
ZE removes the folds of "all" in the eliminate window. Valid only if ' Foldmethod ' is set to ' manual ' or ' marker '.
The common commands are za, zf% and ZD.
Za is on/off folding, zf% is created for matching content, ZD is removed and folded.
Original from: Digdeeply ' s Blog