题
我已经下载了 php.vim 文件,其中包含基于 PHP 的语法信息。它应该能够提供基于语法的折叠,但由于某种原因我无法使其工作。
我已经设定 :let g:php_folding 2
和 :set foldmethod=syntax
但无济于事。我很确定该文件位于正确的位置并且由 vim 读取,因为我可以这样做 :let g:php_sql_query=1
这有效。
这 php.vim
文件位于 ~/.vim/syntax/php.vim
解决方案 3
显然,我的VIM没跑:语法启用
否则:语法使能解决了这一问题,但我还添加:语法上的.vimrc
其他提示
:语法使能:工作(或语法),因为这两个这些选项也打开文件类型检测。文件类型具有折叠或突出工作之前被检测到。
如果你在PHP开发你可能想这三条线添加到您的.vimrc
set nocompatible " Because filetype detection doesn't work well in compatible mode
filetype plugin indent on " Turns on filetype detection, filetype plugins, and filetype indenting all of which add nice extra features to whatever language you're using
syntax enable " Turns on filetype detection if not already on, and then applies filetype-specific highlighting.
然后,你可以把你的let g:php_folding=2
和set foldmethod=syntax
在~/.vim/after/ftplugin/php.vim
文件。
这将让你的.vimrc文件清理,帮助组织所有的设置和使用foldmethod = syntax只会影响PHP文件(如果你想设置的语法为您的默认倍方法对所有filestypes,离开这一行你。 vimrc文件)
有关的更详细信息读取这些帮助文件:
:帮助文件类型,点击 :帮助usr_05.txt结果 :帮助usr_43.txt
我找到了 phpfolding.vim , ,而且非常容易使用。
将 phpfolding.vim 放入 $HOME/.vim/插件/
添加键盘映射
map <F5> <Esc>:EnableFastPHPFolds<Cr>
map <F6> <Esc>:EnablePHPFolds<Cr>
map <F7> <Esc>:DisablePHPFolds<Cr>
好好享受!