More Vim hacks

:set keywordprg=google

Where google is a shell script that simply looks like:

#!/bin/sh
/usr/bin/open http://www.google.com/search?q=$1

The net effect is the whenever I hit K in Vim, I get a google search of the keyword under the cursor. By default Vim uses man, which is OK for C hackers, but not so good for Sun Certified Programmers for Java. :-)

BTW, open is a clever OS X program which uses OS X’s database of applications to find the right application for whatever you tell it to open. In this case it will fire up Safari. Using it here means that this hack works from both the command line and GUI versions of Vim.