Vim settings code folding

Source: Internet
Author: User
Vim settings code folding
Source: chinaunix blog Date: 2008.08.29 (comments in total)I want to comment
 

 When viewing the Code, if the code is very lengthy, especially in the C/C ++ series,
The code structure is hard to clarify, mainly due to the matching of comments and parentheses,
Although % can be used to check where the other half of the matching symbols are, it is hard to understand if the code between the two symbols exceeds one page or even several pages.
Therefore, we can use the folding feature provided by VIM to simplify the analysis.
The Vim I use is a built-in version of rh9.
Fold mode:
Vim provides the folding mode in Step 6.
   Manual    Manual folding
   Indent   More indentation indicates a higher level of collapse
   Expr    Use expressions to define collapse
   Syntax   Use syntax highlighting to define collapse
   Diff     Collapse Unchanged text
   Marker   Fold the mark in the text
You can use the 'foldmethod' option to set the foldmethod: Set OFDM = *****.
Note that each folding method is incompatible, that is, you cannot use expr or marker.
Currently, I usually use more indent instances.
Use the: Set OFDM = indent command to set the marker folding mode.
Add settings in the. vimrc file to enable the folding mode for each opened VI. For example, add set OFDM = syntax.
2. Fold opening and collapse
After the folding method is selected, we can implement the folding we need for some code.
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.
The folding code corresponding to indent is:
ZC Fold
ZC  Collapse all nested folding points within the specified range
Zo Expand and collapse
Zo  Expand All nested folding points in the specified range
[Z To the start of the current fold.
] Z To the end of the currently opened fold.
ZJ Move down. To the start of the next fold. The closed folding is also included.
ZK Move up to the end of the previous fold. The closed folding is also included.
Enter the preceding command in braces for use.
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 :)
You can use the following command to create and delete a fold:
ZF Create 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 the folding of the cursor. Valid only when 'foldmethod' is set to "Manual" or "marker.
ZD  Click Delete to collapse the cursor.
   Valid only when 'foldmethod' is set to "Manual" or "marker.
Ze  Remove all folds in the (eliminate) window.
   Valid only when 'foldmethod' is set to "Manual" or "marker.
Source:

Http://hi.baidu.com/flost_li/blog/item/aede68afcc7955c87dd92af7. Html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.