Open a Perl module from its module name
From Vim Tips Wiki
created 2003 · complexity basic · author Mark Stosberg · version 6.0
This tip shows some techniques for accessing information when editing a Perl program. See also Perldoc function and module keyboard mappings (which should be merged to here).
 Open a Perl module
You may want to open the source code of a system Perl module that's installed. Here's one way to do that:
:e `perldoc -l Module::Name`
The following function will allow you to set your cursor over a Perl module name in the file that you are currently editing and type
\pm to open the corresponding source file in a new buffer:
nnoremap <Leader>pm :call LoadPerlModule()<CR> function! LoadPerlModule() execute 'e `perldoc -l ' . expand("<cWORD>") . '`' endfunction
 View perldoc information
If you use the
K command in Perl files, it will try to invoke '
man' on Perl keywords/functions. But this does not make much sense. It is more useful to redirect
K to use '
perldoc -f' in a Perl file. Add this to your vimrc:
au FileType perl setlocal keywordprg=perldoc\ -T\ -f
K will lookup Perl function names using 'perlfoc -f' for you.
 See also
- Cleanup this and VimTip614, and merge 614 to here.
- Rename this tip.
- I'm pretty sure all the autocmd suggestions are misguided (and should be deleted).
- Instead, show how to use an
The following have suggestions for working with
K that may be helpful in this tip:
- 506 Open Windows Help files on a specific topic
- 598 PHP online help
- 642 Use K to easily run a Windows program for the current word
- 826 PHP manual in Vim help format
- 1341 Power K
- 1533 Vim Doclet
I had a quick try with the
after file, but there is some weird stuff going on with
iskeyword that I'd like to sort out before doing any further cleaning. JohnBeckett 05:28, 5 April 2009 (UTC)