.vimrclately, and this is one of the more useful things I've added. I have forgotten where it came from exactly, but here it is:
let $GROFF_NO_SGR=1 source $VIMRUNTIME/ftplugin/man.vim nmap K :Man <cword><CR>
What's it good for? The default key binding for K (that's "shift-k" I guess) in
vimis to look up the word under the cursor using the
mancommand. The sad thing about this process is that
vimgets replaced by
less(or whatever pager you happen to be using), and that once you're done reading the page, you have to press "Enter" one additional time to get back into
vimand back to whatever you were doing. Kinda breaks your flow, you know?
Once you've added the three lines above to your
.vimrcthings are quite different. When you hit K, the man page opens as a new split window inside of
vimso you're staying in the same environment. All the usual binds for switching between windows work, so you can keep the
manpage open while going back to your code. Better yet, the
manpage will be "syntax highlighted" using different colors for headings, text, and (you guessed it) references to other
manpages. And the best thing? You can browse
manpages the same way you browse
tags: use "ctrl-]" to open another
manpage and use "ctrl-t" to "go back" to the previous one.
Now that's how
manpages were supposed to be integrated with your editor. Very nice indeed... :-D
There's one small problem that I have not been able to work around yet: The original K could be preceded by the section number to look in, but this won't work in the replacement above. I am not enough of a
vimhacker yet to add that capability. Shame on me?
Update: Actually, I forced myself to learn just enough of
vimscriptto cobble together something ugly for section numbers:
" experimental hack to get section numbers to work as well function ManWrapper(n, w) if a:n > 0 let cnt = a:n-line(".")+1 execute "Man" cnt a:w else execute "Man" a:w endif endfunction com -count=0 -nargs=+ CMan :call ManWrapper(<count>, <f-args>) nmap X :CMan <cword><cr>
Yes, I know, it's quite horrific! If you know this dreadful language better, please tell me how to rewrite this cleanly.