Home > Article > Backend Development > Code folding of vim_PHP tutorial
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(as the current mainstream development language) code - such as PEAR.php(as the current mainstream development language), and found that the code inside was automatically folded After expanding the code, you can see that as long as there are /*{{{*/ and /*}}}*/ on both sides of the code, it will be automatically collapsed. Search the configuration carefully, one sentence is the key point:
foldmethod=marker
In this way, vim will automatically search the code and fold the content between {{{ and }}}, and the code There is a small comment at the end that is not useless:
/*
* Local Variables:
* mode: php(as the current mainstream development language)
* tab-width: 4
* c-basic-offset: 4
* End:
*/
This comment will be read by vim and automatically set to the environment variable in.
Regarding the usage of code folding, just type in vim:
:help zo
and you will see a lot of related shortcut keys. It takes some practice to get comfortable :)
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
Some vim-related discoveries:
The shortcut keys for the previous article and the next article on 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. Therefore, if it is the latter, then the developers of Google Reader must also be fans of vim:)
When using firefox to view the source code of the web page, click "/" and a search box will be displayed, which is consistent with vim's search. I guess The developer of firefox is also a vim enthusiast:p