Showing posts with label keywordprg. Show all posts
Showing posts with label keywordprg. Show all posts

Wednesday, February 11, 2009

VIM's keywordprg for Perl and ... VIM itself

This is logical follow-up to my previous post about K shortcut.

The two (actually three lines) added to ~/.vimrc allow when editing Perl and VIM scripts to transparently call with K proper help system.

au BufReadPost *.pl   set keywordprg=perldoc\ -f
au BufReadPost *.vim map K :exe ":help ".expand("<cword>")<CR>
au BufReadPost .vimrc map K :exe ":help ".expand("<cword>")<CR>


Perl one is obvious. VIM one actually required some trickery: we do not call external program, but call VIM's internal command instead.

P.S. BTW, :help :help is pretty useful reading. Due to my error, 'K' in VIM mode used to constantly show it, instead of expected 'expand("<cword>")'.