Wikia

Vim Tips Wiki

Changes: Open a Perl module from its module name

Edit

Back to page

(Open a Perl module)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 29: Line 29:
   
 
==View perldoc information==
 
==View perldoc information==
If you use the <tt>K</tt> command in Perl files, it will try to invoke '<tt>man</tt>' on Perl keywords/functions. But this does not make much sense. It is more useful to redirect <tt>K</tt> to use '<tt>perldoc -f</tt>' in a Perl file. Add this to your [[vimrc]]:
+
If you use the <code>K</code> command in Perl files, it will try to invoke '<code>man</code>' on Perl keywords/functions. But this does not make much sense. It is more useful to redirect <code>K</code> to use '<code>perldoc -f</code>' in a Perl file. Add this to your [[vimrc]]:
 
<pre>
 
<pre>
 
au FileType perl setlocal keywordprg=perldoc\ -T\ -f
 
au FileType perl setlocal keywordprg=perldoc\ -T\ -f
 
</pre>
 
</pre>
   
and <tt>K</tt> will lookup Perl function names using 'perlfoc -f' for you.
+
and <code>K</code> will lookup Perl function names using 'perlfoc -f' for you.
   
 
==See also==
 
==See also==
Line 44: Line 44:
 
*Rename this tip.
 
*Rename this tip.
 
*I'm pretty sure all the autocmd suggestions are misguided (and should be deleted).
 
*I'm pretty sure all the autocmd suggestions are misguided (and should be deleted).
*Instead, show how to use an <tt>after/ftplugin/perl.vim</tt> file.
+
*Instead, show how to use an <code>after/ftplugin/perl.vim</code> file.
   
The following have suggestions for working with <tt>K</tt> that may be helpful in this tip:
+
The following have suggestions for working with <code>K</code> that may be helpful in this tip:
 
*[[VimTip506|506 Open Windows Help files on a specific topic]]
 
*[[VimTip506|506 Open Windows Help files on a specific topic]]
 
*[[VimTip598|598 PHP online help]]
 
*[[VimTip598|598 PHP online help]]
Line 54: Line 54:
 
*[[VimTip1533|1533 Vim Doclet]]
 
*[[VimTip1533|1533 Vim Doclet]]
   
I had a quick try with the <tt>after</tt> file, but there is some weird stuff going on with <tt>iskeyword</tt> that I'd like to sort out before doing any further cleaning. [[User:JohnBeckett|JohnBeckett]] 05:28, 5 April 2009 (UTC)
+
I had a quick try with the <code>after</code> file, but there is some weird stuff going on with <code>iskeyword</code> that I'd like to sort out before doing any further cleaning. [[User:JohnBeckett|JohnBeckett]] 05:28, 5 April 2009 (UTC)
   
 
----
 
----

Latest revision as of 05:31, July 13, 2012

Tip 461 Printable Monobook Previous Next

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 moduleEdit

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 informationEdit

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

and K will lookup Perl function names using 'perlfoc -f' for you.

See alsoEdit

Online documentation for word under cursor

CommentsEdit

 TO DO 

  • 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 after/ftplugin/perl.vim file.

The following have suggestions for working with K that may be helpful in this tip:

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)


Around Wikia's network

Random Wiki