The default behavior of the K command is to lookup the keyword under the cursor using man. This is handy at times, but it's not very useful when I spend 90% of my day writing PHP code. Vim's online help mentions that you can set keywordprg to an alternative program, so I did the following.
set keywordprg=/home/travis/pdoc
Where pdoc is the following shell script:
#!/bin/sh
firefox http://us3.php.net/manual/en/function.$1.php
Now I can move the cursor over a builtin function, hit K, and firefox will open to the appropriate documentation. To keep things strictly textual, you could use lynx (or links) in lieu of firefox.
For ruby code, I like to do the following:
set keywordprg=ri
For Perl:
set keywordprg=perldoc\ -tf
Showing posts with label keyword. Show all posts
Showing posts with label keyword. Show all posts
Friday, August 15, 2008
Monday, May 5, 2008
Completion
This is one of my favorite features in Vim. In fact, I use it so often that it didn't occur to me until recently that some people may not take advantage of it. If you're familiar with getting around on a modern shell (bash, csh, zsh, etc...), you're almost certainly acquainted with command completion. Vim offers a similar facility that works on the current buffers you have open (although it can do ex command completion as well ;-). When working in your current window, simply type a portion of a string (i.e., hereIsAReallyLong...) then hit ctrl-n. Vim should display a menu of possible completion options. Scroll up and down the menu with ctrl-p and ctrl-n. Hit enter when you find the entry you want to insert. This saves a lot of typing on longer method names and strings and also helps avoid spelling typos. If you find ctrl-p and ctrl-n too cumbersome to type or simply want to make completion feel more like it does on the shell, you can grab the SuperTab Plugin and use that instead.
Side tip: inside of ex mode, you can just use the tab key to complete your ex commands.
Side tip: inside of ex mode, you can just use the tab key to complete your ex commands.
Subscribe to:
Posts (Atom)