VimCodeFold
You can use the "foldmethod" option to set the vim code folding method, for example, set foldmethod = indent.
There are 6 Ways to collapse the code
1. Manual // manually define the folding
2. indent // fold with indentation
3. expr // use an expression to define the fold
4. Syntax // use syntax highlighting to define collapse
5. Diff // fold Unchanged text
6. Marker // hide with a flag
Vim configuration files are dividedGlobal configuration fileAndUser Configuration File
1. Search for the global configuration file. In. Vim, enter echo $ vim, which is generally/usr/share/Vim/vimrc.
2. the user configuration file is in the user's home directory, for example,/home/abeen/. vimrc.
Set the folding mode in the vimrc file, for example, set foldmethod = indent.
After the folding mode is selected, you can use the folding command to perform the folding operation. The common folding modes are indent and marker.
Indent folding command
Indent mode. Vim automatically uses indentation for folding. We can use the ready-made folding results.
Enter the following command in the fold:
ZC folding
ZC folds all nested folding points in the range
Zo unfold and fold
Zo expands all nested folding points in the range
[Z to the start of the current fold.
] Z to the end of the currently opened fold.
ZJ moves down. To the start of the next fold. The closed folding is also included.
ZK moves up to the end of the previous fold. The closed folding is also included.
Marker folding command
When the marker folding method is used, we need to use a tag to identify the code folding. The default value is {And }}}
Fold command
ZF creates a fold, for example, in the marker mode:
Zf56g: Creates code folding from the current row to 56 rows;
10zf, 10zf +, or zf10 labels, create code folding from the current row to the last 10 lines.
10zf-or zf10 labels, create code folding from the current row to the previous 10 lines.
At ZF %, create the matching brackets (), {}, [], <>, etc.) from the current row ).
ZD Delete is the folding of the cursor. Valid only when 'foldmethod' is set to "Manual" or "marker.
ZD loop Delete refers to the folding under the cursor, that is, nesting Delete fold. Valid only when 'foldmethod' is set to "Manual" or "marker.
Ze removes all folds in the (eliminate) window. Valid only when 'foldmethod' is set to "Manual" or "marker.
After folding