日期:2011-11-29  浏览次数:20502 次

  首先说个题外话: Vim发布7.3了..

  在翻看Vim插件的时候, 发现了一个比较有意思的应用(非插件): 把PHP的手册融如Vim中, 在Vim中, 按”K”, 就可以跳转到光标下函数的手册说明…

  1. 首先, 下载特殊定制的PHP手册(包含PHP5.3的所有函数) : vim-php-manual.tar.gz

  2. 把下载的文件解压缩, 放置到一个目录, 比如/tmp/phpmuanul(windows下比如:”d:/phpmanual”).

  3. 配置vimrc(linux下是.vimrc,windows下是_vimrc), 把phpmanual目录添加到runtimepath(稍后解释为什么).

  4. 配置vimrc, 使得keywordprg=”help”. 在我的机器上, keywordprg默认是!man, 大多数时候, 我还是希望可以直接man到linux下的标准函数库, 所以我使用(在vimrc文件中):

  autocmd BufNewFile,Bufread *.ros,*.inc,*.php set keywordprg="help"

  或者也可以写在vim目录下的ftplugin下的php.vim(如果没有新建), 这样在ft为php的时候,这个配置脚本就会被加载.

  至于说, 为什么要把phpmanual目录添加到runtimepath, 是因为:

  When no argument is given to :help the file given with the 'helpfile' optionwill be opened. Otherwise the specified tag is searched for in all "doc/tags"files in the directories specified in the 'runtimepath' option.

  意思就是说, 在vim中, 调用help的时候, help会去所有的runtimpath下的doc目录中寻找tags文件, 来寻找要查找的帮助关键字.

  在我们下载的vim-php-manual.tar.gz文件中, 就包含了doc/tags这样的文件目录结构, 所以只要把phpmanual目录加入runtimepath, 并且设置keywordprg为vim的help, 就可以实现在光标处按”K”跳转到函数手册了.

  

\

 

  使用截图

  最后,补充一点, 如果在使用的时候,Vim提示你:

  tags file not sorted

  那你就用vim打开phpmanual/doc/tags, 然后%sort一下就可以了…