VIM Code Folding

Source: Internet
Author: User

VIM Code Folding Vim code folding can be set using the "foldmethod" option, such as: Set Foldmethod=indent

There are 6 ways to fold code

1. Manual//manually define folding 2. Indent//With indentation for folding 3. Expr//Use an expression to define the folding 4. Syntax//Use syntax highlighting to define folding 5. Diff//collapse 6 for text that is not changed. Marker//Folding with logo

The vim configuration file is divided into global profile and user profile

1. Global profile lookup, input in. Vim: Echo $VIM, generally:/USR/SHARE/VIM/VIMRC 2. User profiles in the user's home directory, such as:/HOME/ABEEN/.VIMRC

Set the folding method in the VIMRC file: such as set foldmethod=indent

Once you have selected a folding method, you can use the collapse command to collapse the operation. The usual folding methods are indent and marker.

Indent folding Command indent way, VIM will automatically use indentation for folding, we can use ready-made folding results. We can enter the following command in the fold:

ZC Folding ZC Collapses all nested collapsed points within the range Zo expand collapse zo all nested collapsed points within the range expand [Z to the beginning of the currently open collapse. ]z to the end of the currently open fold. The ZJ moves down. arrives at the beginning of the next collapse. Closed folds are also counted. ZK moves up to the end of the previous fold. Closed folds are also counted.

Marker Folding Command marker folding mode, we need to use a tag to identify the collapse of the code, the system default is {{{and}}} collapse command

ZF creates folding, such as in marker mode: zf56g, creates a code folding from the current line to 56 lines, 10ZF or 10zf+ or zf10↓, creates a code collapse from the current line to the next 10 lines.         10zf-or zf10↑, creates a code collapse from the current line to the previous 10 lines. zf% at the parentheses, creating the corresponding matching parentheses ((),{},[],<>, etc.) from the current line. ZD Remove (delete) is collapsed under the cursor. Valid only if ' Foldmethod ' is set to ' manual ' or ' marker '. ZD Loop Delete (delete) is collapsed under the cursor, that is, nested delete collapses. Valid only if ' Foldmethod ' is set to ' manual ' or ' marker '. ZE Remove the "all" folding in the (Eliminate) window. Valid only if ' Foldmethod ' is set to ' manual ' or ' marker '.

VIM Code Folding

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.