Personalized Vim folding

Source: Internet
Author: User

Manual folding:
Zfap
You will see that this section is replaced by a highlighted line of text. You have created a fold. | ZF | it is an operator, and | AP | it is a text object. You can use the | ZF | Operator together with any mobile command to create a fold for the text in which it passes. | ZF | it can also be used in visual mode.
Note: AP is used to select a paragraph. The usage of A is as follows:
 
"" This is a example ""
The method used is <action> A <ID, which can be ', ",],}, and so on>
"This is a example" will be selected as long as VA is entered in the double quotation marks of the inner layer"
You can also enter y2a in the double quotation marks to copy "This Is A Example ""
 
{This is another example}
If you enter va} anywhere in {}, {This is another example} is copied }.
 
Zf20g fold from current position to 20 rows
Zfgg is collapsed from the current position to the file header, which is very suitable for hiding header file inclusion at the top of the file during programming, source file Annotation
 
 
Frequently Used by authors:
When writing a program, the Unit is a function. You can easily fold a function and keep the function header. The following function: move the cursor to {and enter ZF %.
# Include <stdio. h>
Int main (INT argc, char * argv [])
{
Return 0;
}
 
 
The effect is as follows:
# Include <stdio. h>
Int main (INT argc, char * argv [])
+: -- 3 rows {-------------------------------------------------}
 
 
To read more text, type the following command to open the fold:
Zo
 
You can also run the following command to disable the fold:
ZC
 
All the folding commands start with 'Z. Show your imagination, the letter looks like a fold
The side of the paper. The available letters behind "Z" can be easily remembered as they are selected using the help memory method:
 
Zf f-old creation (create fold)
Zo o-pen a fold (open and fold)
Zc c-lose a fold (hide)
 
 
Open all folds at a time:
ZR Zr (used for Recursive folding, similar to ZR)
Close all folds at a time:
ZM (used for Recursive folding, similar to ZM)
 
 
More common commands:
Zi (after we create a fold, we can use Zi to close all folds, move the cursor to the text to be viewed, and then press Zi to open all folds)
 
 
Fold control:
Sometimes it is not easy to view or remember where a piece is folded. Let alone the | Zo | command. To Query
See the defined folds:
 
: Set foldcolumn = 4
 
This command will display a small column on the left of the window to identify each fold. A "+" indicates a closed fold. I
"-" Indicates the beginning of each opened fold, while "|" indicates the rest of the rows in the fold.
Remove the left sidebar:
: Set foldcolumn &
 
You can click "+" in the fold column to open a fold. Click "-", or
"|" To close an opened fold.
 
Store and restore a fold:
When you close a file, do other things, or edit another file, and then edit the same file, if it is manually created, all the folds will disappear! To save and fold, you can use:
: Mkview
This stores the settings that affect the File View and other content.
When you return to the same file later, you can re-load the View:
: Loadview
 
You can store up to ten views for one file. For example, save the current settings as the third view and load
Two views:
 
: Mkview 3
: Loadview 2
 
 
Dependency indent collapse:
If you want to collapse the dependency indentation, you must first set
: Set foldmethod = indent
 
If the code you write is more standardized, it will be fine if it is not standardized. Select all the codes first, and then press "=" to normalize the code. The complete command is ggvg =
Then try zm and Zr. This function is quite useful to programmers. After foldmethod is set, we can no longer manually create a foldmethod. For this feature that I like and do not like to be constrained, it is not a bad thing.
We only need to reset the foldmethod.
: Set foldmethod)
 
Other folding methods:
Dependency ID folding
Dependency syntax collapse
Dependency expression collapse
See http://vimcdoc.sourceforge.net/doc/usr_28.html#28.6
References: http://vimcdoc.sourceforge.net/doc/usr_28.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.