Vim Tips Wiki
Tip 1200 Printable Monobook Previous Next

created April 8, 2006 · complexity basic · author bigkm · version 5.7

Open's documentation with the word underneath the cursor

noremap gd ! open [<cword><CR><cword><CR>];


I couldn't find a way to open the php manual in an already-open window except by compiling Firefox myself. Instead I had to go with re-launching the browser each time I wanted to check the manual. Also, in order to launch Firefox when it is already running, the new instance will need a separate profile, so it does get a litte complicated:

function OpenPHPManual(keyword)
  let firefox = '/Applications/'
  " you will need to create this profile in firefox
  let profile = 'Profile for PHP Manual'
  let url = '' . a:keyword
  exec '!' . firefox . ' -p "' . profile . '" "' . url . '"'
noremap gd :call OpenPHPManual(expand('<cword>'))<CR>

In recent Firefox versions (2014 and probably earlier) there is a -no-remote option.

On my GNOME system I use "gnome-open"; to open the default browser (Firefox). I've configured Firefox to open new windows in new tabs if a browser is already open.

For mozilla, informations here:

Manpageview supports php help (it uses links), for example:

:Man bzopen

while in a file identified by the syntax highlighting as being php.

Here is what I did. I use lynx to see the documentation, but the documentation at has some menu stuff I don't want to see (I have to scroll everytime). And the speed is slower than if it were local. So I downloaded the doc files and put it on my webserver. I still want to search the php website if i cant remember the function name. So i added two options:

function OpenPHPManual(keyword)
  let web = 'lynx -accept_all_cookies --cookie_file=/home/jon/.lynx_cookies --cookie_save_file=/home/jon/.lynx_cookies --cookies'
  let url = '' . a:keyword
  exec '!' . web . ' "' . url . '"'

function OpenPHPManualLocal(keyword)
  let web = 'lynx'
  let url = '' . a:keyword . '.html'
  exec '!' . web . ' "' . url . '"'

noremap fd :call OpenPHPManualLocal(expand('<cword>'))<CR>
noremap fj :call OpenPHPManual(expand('<cword>'))<CR>

Add a -nopause to the above lynx command. It makes getting the files from PHP's mirrors faster.

If you are using Mac OS X you can use the 'open' command which tries to use an existing Firefox window:

:!open [<cword><cword>];

If you use 'sudo vim ...' then you're running 'open' as Admin User, which may still have Safari as the default browser, in which case you can use 'sudo /Applications/Firefox...' to start firefox as Admin and set Firefox as the default web browser.