Search code examples
phpvimmanpage

Reading PHP man pages in Vim


I have setup the ability to read the PHP manual via pman as described here: http://bjori.blogspot.com/2010/01/unix-manual-pages-for-php-functions.html

In my .vimrc file I have added the following so I can press K to read the man page in a new split window.

source $VIMRUNTIME/ftplugin/man.vim
nnoremap K :Man <cword><cr>

This works perfectly, sometimes. Certain functions show the man pages just as you would expect. Others, I get the error "Cannot find a 'method_exists'.", for example. First, I wondered if the man pages were out of date but it doesn't seem as they are.

If I run pman method_exists from the terminal, I see the expected man page.

Does anyone have any idea why only some of the man pages appear correctly inside of Vim?

Thanks!


Solution

  • I have found that when pressing K would show man pages for some keywords only because those keywords also had man pages associated. I didn't inspect the man page close enough to notice that it wasn't for the PHP keyword.

    I had to specify the man path before this would work properly. I have updated the lines in my ~/.vimrc to the following:

    source $VIMRUNTIME/ftplugin/man.vim
    nnoremap K :Man --manpath=/usr/share/doc/php5-common/PEAR/pman/ <cword><cr>
    

    Thanks for the help and suggestions!