Wikia

Vim Tips Wiki

Changes: View PHP documentation for current word

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
Line 15: Line 15:
   
 
<pre>
 
<pre>
noremap gd ! open [http://php.net/<cword><CR> http://php.net/&lt;cword&gt;&lt;CR&gt;];
+
noremap gd ! open [http://php.net/<cword><CR> http://php.net/<cword><CR>];
 
</pre>
 
</pre>
   
Line 29: Line 29:
 
exec '!' . firefox . ' -p "' . profile . '" "' . url . '"'
 
exec '!' . firefox . ' -p "' . profile . '" "' . url . '"'
 
endfunction
 
endfunction
noremap gd :call OpenPHPManual(expand('&lt;cword&gt;'))&lt;CR&gt;
+
noremap gd :call OpenPHPManual(expand('<cword>'))<CR>
 
</pre>
 
</pre>
   
Line 62: Line 62:
 
endfunction
 
endfunction
   
noremap fd :call OpenPHPManualLocal(expand('&lt;cword&gt;'))&lt;CR&gt;
+
noremap fd :call OpenPHPManualLocal(expand('<cword>'))<CR>
noremap fj :call OpenPHPManual(expand('&lt;cword&gt;'))&lt;CR&gt;
+
noremap fj :call OpenPHPManual(expand('<cword>'))<CR>
 
</pre>
 
</pre>
   
Line 73: Line 73:
   
 
<pre>
 
<pre>
:!open [http://www.php.net/<cword> http://www.php.net/&lt;cword&gt;];
+
:!open [http://www.php.net/<cword> http://www.php.net/<cword>];
 
</pre>
 
</pre>
   

Revision as of 00:02, September 30, 2008

Tip 1200 Printable Monobook Previous Next

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


Open php.net's documentation with the word underneath the cursor

noremap gd ! open [http://php.net/<cword><CR> http://php.net/<cword><CR>];

Comments

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/Firefox.app/Contents/MacOS/firefox-bin'
  " you will need to create this profile in firefox
  let profile = 'Profile for PHP Manual'
  let url = 'http://www.php.net/' . a:keyword
  exec '!' . firefox . ' -p "' . profile . '" "' . url . '"'
endfunction
noremap gd :call OpenPHPManual(expand('<cword>'))<CR>

On my GNOME system I use "gnome-open http://domain.com"; 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: http://www.mozilla.org/unix/remote.html


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 PHP.org 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 = 'http://jp2.php.net/' . a:keyword
  exec '!' . web . ' "' . url . '"'
endfunction

function OpenPHPManualLocal(keyword)
  let web = 'lynx'
  let url = 'http://192.168.0.2/~jon/phpdoc/function.' . a:keyword . '.html'
  exec '!' . web . ' "' . url . '"'
endfunction

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 [http://www.php.net/<cword> http://www.php.net/<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.


Around Wikia's network

Random Wiki