Vim code folding

Source: Internet
Author: User
The code folding of vim, reading the code folding of vim, vim also has the code folding function. it was previously known that, after all, it is rarely used, and this function is rarely used. With the recent close contact with gvim, the code folding feature has become increasingly familiar. One time I opened a piece of php code, such as PEAR. php, and found that the code in it was automatically folded, replacing "> <LINKhref =" http: // www.

Vim also has the code folding function. it was previously known that, after all, it is rarely used. With the recent close contact with gvim, the code folding feature has become increasingly familiar. Once I opened a piece of php code, such as PEAR. php, the code in it is automatically folded. after the code is expanded, you can see that as long as there are/* {*/and/*} */on both sides of the code /*}}}*/, it is automatically folded. Search for configuration carefully. one of the following statements is important:

Foldmethod = marker

In this way, vim will automatically search for the code, fold the content between {and}, and a small comment at the end of the code is not useless:

/*
* Local Variables:
* Mode: php
* Tab-width: 4
* C-basic-offset: 4
* End:
*/

This annotation will be read by vim and automatically set to the environment variable.

For code folding usage, enter the following in vim:
: Help zo
You can see a lot of related shortcut keys, you need some exercises to be handy :)

My gvim configuration content has been added:

Colo zellner
Set guifont = Courier_New: h11: cANSI nobackup tabstop = 4 shiftwidth = 4 foldmethod = marker
Au BufRead * simalt ~ X

Minor vim-related discoveries:

In the previous article of google reader, the next shortcut key is j, k, which is consistent with the vim cursor moving key. I don't know whether it is a coincidence or intentional one. if it is the latter, so google reader developers must also be fans of vim :)
When you use firefox to view the webpage source code, click "/" to display the search box, which is consistent with the vim search. it is estimated that firefox developers are also vim fans: p

Http://www.ooso.net/index.php/archives/183

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.