PHP语言, PHP扩展, Zend引擎相关的研究,技术,新闻分享 – 左手代码 右手诗

18 Aug 10 将PHP Manual融入(g)Vim

首先说个题外话: 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' option
will 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一下就可以了…


Related Posts:

Tags: , , , ,

35 Responses to “将PHP Manual融入(g)Vim”

  1. sign in |

    Hotmail sign-in instructions for everyone

  2. jual wire mesh di bekasi |

    There is certainly a lot to find out about this
    issue. I really like all the points you have made.

  3. 风雪之隅-鸟哥文章汇总 | 互联网菜鸟 |

    [...] 26 Jul 10 PHP运算符优先级的一个例外  30 Jul 10 注意PHP对字符串的递增运算 18 Aug 10 将PHP Manual融入(g)Vim [...]

  4. grow lights |

    Everything published made a ton of sense. However, what about this?

    what if you wrote a catchier title? I am not saying your information is
    not solid, however what if you added a title that makes people desire more?
    I mean 将PHP Manual融入(g)Vim | 风雪之隅 is kinda
    vanilla. You should peek at Yahoo’s home page and note how they
    create article headlines to grab viewers to click.
    You might add a related video or a pic or two to get people interested about what you’ve written.
    Just my opinion, it could bring your posts a
    little bit more interesting.

  5. amish friendshp bread starter |

    Heya! I know this is kind of off-topic however I needed to ask.
    Does operating a well-established blog such as yours take a large amount of work?
    I’m completely new to writing a blog but I do write in my diary every day. I’d like to start a blog so I can easily
    share my experience and views online. Please
    let me know if you have any ideas or tips for brand
    new aspiring blog owners. Appreciate it!

  6. karen millen dress |

    For example, a complete 3-5 kilowatt gadget might cost $200 Euros and latest 20-30 years.
    Further items include jewelry, belts, shoes so coats.
    Hertz is the unit in which persistence is measured. The love
    of using dress up, became as she performed. karen millen dress.

  7. haix |


  8. North Face Women's Apex Bionic |

    Very nice style and fantastic articles , nothing at all else we need : D.

  9. VIM做PHP开发环境 « shanks的海贼船 |

    [...] 等 参考 参考 [...]

  10. 龙安 |


  11. pinyht's Blog » 自制vim中文版php手册 |

    [...] [...]

  12. vim配置 | Ocean技术博客 |

    [...] buffer_explorer:be 出已在buffer的文件列表 phpmanual来自鸟哥博客 有参照 其它东拼西凑了些,都瞎找的,不知道哪了 [...]

  13. 将PHP_Manual整合到Gvim » ReadMoon |

    [...] 今天在看到将PHP_Manual整合到Gvim,就照着做了一遍,可是按K键,gvim提示:E149:抱歉,没有 ***** 的说明。重新检查一遍,都没有错呀,用:set runtimepath<CR>查看,manual的路径也在runtimepath里面了,但就是不行,又找不到原因。根据里面的说明: [...]

  14. 何林丹 |

    set runtimepath +=d:/phpmanual


  15. DoMyself » Blog Archive » VIM做PHP开发环境 |

    [...] 等 参考 参考 [...]

  16. Anonymous |

    E149: Sorry, no help for dirname

  17. liuzhiqiang |


  18. pandora jewelery |


  19. liruqi |


  20. moncler |

    then run :helptags [path to vim/doc]. Documentation for PHP functions can be shown by pressing K while the cursor is on a function name.

  21. pangyongtao |

    Download and put it into your vim/doc folder, then run :helptags [path to vim/doc]. Documentation for PHP functions can be shown by pressing K while the cursor is on a function name.

    虽然版本旧, 不过部署方法简单, 呵呵

  22. 雪候鸟 |

    @wl 已经添加, 私聊

  23. wl |




    希望能得到你的帮助,我找不到你的IM联系方式,请加我QQ, 24327475 谢谢

  24. christian louboutin shoes |


  25. Yurtdışı Eğitim |

    Is this web site availible in English?

  26. 技术网 |


  27. air max shoes |

    是挺慢的 不过很好用哦!

  28. nfl football jerseys |


  29. 谷哥QQ |


  30. 张二 |

    呵呵,试了一下,果然V5,比较懒,set runtimepath发现.vim/doc已经包含在runtimepath变量中了,由于直接cd ~/.vim,然后解压了鸟哥的包(好多文件),然后设置了一下.vimrc……很好用哦。

  31. Tweets that mention 将PHP Manual融入(g)Vim | 风雪之隅 -- |

    [...] This post was mentioned on Twitter by 惠新宸, glemir and 惠新宸, Wing. Wing said: 說 ([rep])@jaceju : (将PHP Manual融入(g)Vim) [...]

  32. simplechen |

    兄弟你是用VIM的老手了,能否分享一下你的VIM配置。:) 多谢!

  33. 雪候鸟 |

    @felix021 :help和”help”(有引号)都可, :)

  34. felix021 |


    另外,keywordprg应该是 :help
    autocmd FileType php set keywordprg=:help

  35. xiaokai |


Leave a Reply