Vim also has a code folding function, which I have known before, but after all, it is not used much, so this function is basically rarely used. With my recent close contact with gvim, I have gradually become familiar with the code folding function. Once I opened a piece of php code - such as PEAR.php, I found that the code inside was automatically folded. After expanding the code, I can see that as long as there are /*{{{*/ and /*}}}*/ on both sides of the code, will be automatically folded. Search the configuration carefully, and one sentence is the key point:
foldmethod=marker.
In this way, vim will automatically search the code and fold the content between {{{ and }}}. Moreover, a small comment at the end of the code is not useless waste:
/ *
* Local Variables:
*mode: php
*tab-width: 4
* c-basic-offset: 4
*End:
*/
This comment will be read by vim and automatically set to the environment variable.
Regarding the usage of code folding, just enter in vim:
:help zo
You can see a lot of related shortcut keys, which require some practice before you can get comfortable with them:)
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
A little vim-related discovery:
The shortcut keys for the previous article and the next article in google reader are j and k respectively, which are consistent with the cursor movement keys of vim. I don’t know if it is a coincidence or intentional. If it is later , then the developers of google reader must also be fans of vim:)
When using firefox to view the source code of a web page, click "/" and a search box will be displayed, which is consistent with vim's search. It is estimated that the developers of firefox are also vim enthusiasts:p