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

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: , , , ,

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

  1. 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.

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

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

  3. 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.

  4. 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!

  5. 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.

  6. haix |

    文中地址已失效,这个地址可以用,已经经过实测可用!
    http://vim.wikia.com/wiki/PHP_manual_in_Vim_help_format

  7. North Face Women's Apex Bionic |

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

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

    [...] 等 参考http://koch.ro/blog/index.php?/archives/63-VIM-an-a-PHP-IDE.html 参考http://www.laruence.com/2010/08/18/1718.html [...]

  9. 龙安 |

    下载链接已经失败了,压缩包错误,另外官方的也下不了了,更新下地址吧

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

    [...] http://www.laruence.com/2010/08/18/1718.html [...]

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

    [...] buffer_explorer:be 出已在buffer的文件列表 phpmanual来自鸟哥博客http://www.laruence.com/2010/08/18/1718.html 有参照http://nootn.com/blog/Tool/22/ 其它东拼西凑了些,都瞎找的,不知道哪了 [...]

  12. 将PHP_Manual整合到Gvim » ReadMoon |

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

  13. 何林丹 |

    操作把phpmanual目录添加到runtimepath
    set runtimepath +=d:/phpmanual

    需注意几点:
    1.=与路径之间不能有空格
    2.window下时路径中不能有空格。
    3.路径不能加双引号
    4.多个路径需要逗号(半角)隔开

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

    [...] 等 参考http://koch.ro/blog/index.php?/archives/63-VIM-an-a-PHP-IDE.html 参考http://www.laruence.com/2010/08/18/1718.html [...]

  15. Anonymous |

    楼主,我按照你说的做了,可以就是找不到,提示的错误是
    E149: Sorry, no help for dirname
    不知道是为什么,烦请解答

  16. liuzhiqiang |

    恩,这样确实很方便,以后就不用去manual了。尤其上不去网的时候,最揪心。

  17. pandora jewelery |

    thankaaaaaaaaa

  18. liruqi |

    配置成功,thanks~~~

  19. 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.

  20. pangyongtao |

    Download http://planetxml.de/php_manual.txt 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.

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

  21. 雪候鸟 |

    @wl 已经添加, 私聊

  22. wl |

    真心求教
    看了你的这些文章,感觉不是很系统,有些看不明白。
    能不能给点指点?

    我想把smarty写成扩展模块。

    刚刚做了个demo,实现了简单的变量替换。

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

  23. christian louboutin shoes |

    博主是高人,这样的编程都会啊

  24. Yurtdışı Eğitim |

    Is this web site availible in English?

  25. 技术网 |

    还没试用,先谢谢分享

  26. air max shoes |

    是挺慢的 不过很好用哦!

  27. nfl football jerseys |

    博主绝对是VIM高手,提供的很详细,刚试了一下,很好用,谢谢了

  28. 谷哥QQ |

    感谢分享!

  29. 张二 |

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

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

    [...] This post was mentioned on Twitter by 惠新宸, glemir and 惠新宸, Wing. Wing said: 說 http://www.plurk.com/p/70diq1 ([rep])@jaceju : http://tinyurl.com/25dqjgl (将PHP Manual融入(g)Vim) http://plurk.com/p/70igkh [...]

  31. simplechen |

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

  32. 雪候鸟 |

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

  33. felix021 |

    感谢分享!
    .tar.gz下载有点儿慢。

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

  34. xiaokai |

    下班回家试试..

Leave a Reply

*