VIM code Folding: Set Foldmethod=marker

Source: Internet
Author: User
Tags valid

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

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.