1. Folding Mode You can use the 'foldmethod' option to set the foldmethod: Set OFDM = *****. There are 6 Ways to select the fold: Manual manual definition folding More indent indicates more fold Expr uses expressions to define collapse Syntax uses syntax highlighting to define collapse Diff folds Unchanged text Marker folds the mark in the text Note that each folding method is incompatible. If expr is not used and marker is used, the indent and marker modes are used in turn. When using this function, use the: set OFDM = marker command to set it to the marker foldmethod ). To make the folding take effect every time vim is opened, add the settings in the. vimrc file, such as adding: set OFDM = syntax, just like adding other initialization settings. 2. Fold command After the folding method is selected, we can implement the folding we need for some code. Because I use more indent and marker, their usage is used as an example: If the indent method is used, vim automatically folds the middle part of the braces, and we can directly use these ready-made folding results. In a foldable place (in the middle of braces ): 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. When using the marker method, you need to use a tag to identify code folding. The default value of the system is {And}. Do not change it :) We can use the following command to create and delete a fold: 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. |