If you program in C you probably look to the man pages as a prime reference. There are a lot of different functions in the standard library. For example, what does this all mean?

sscanf(str, "%*d: %12[^a-zA-Z] 0x%4x %n", ...)

Luckily in Vim I can just press K over sscanf and in a window split I'll have the man page. Now this isn't a new feature, except that the man page opens in a Vim window not in a pager. This is a feature enabled by enabling a plugin that ships with Vim.

As an additional bonus the man page has syntax highlighting and is tagged so you can travel between man pages with CTRL-] and CTRL-T. Now when you see the references (like getc(3)) you can just scroll over and hit CTRL-] to view it.

To enable this plugin, and map K to use it, add to your .vimrc:

runtime ftplugin/man.vim
nmap K :Man <C-R>=expand("<cword>")<CR><CR>

Now you'll always have man pages at your finger tips without ever leaving Vim!

Posted: Mar 21, 2008 | Tags: programming tips

Comments are closed.

Tags

42 | django | python | oggify | OSCON | OSCON07 | osx | utosc | mythtv | security | reading | music | gaming | programming | tips | shell | vim | pyobjc | cocoa | iphone | blog | git

Calendar

<< Mar >>
Mo Tu We Th Fr Sa Su
25 26 27 28 29 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 1 2 3 4 5 6

Search

This space reserved for a search box

A Django site. Hosted on a Slicehost Slice