If you're primarily a Perl hacker and don't use C much, you might find it annoying when you hit 'K' in command mode. That's because VIM runs something like this:

nmap K :Map <cword><cr>

Instead, add the following snippet to your .vimrc and when you type 'K' in command mode, it will call up the appropriate perldoc, if possible.

I really should have added that to Perl Hacks. Damn.

noremap K :!perldoc <cword> <bar><bar> perldoc -f <cword><cr>

Replies are listed 'Best First'.
Re: Integrating Perldoc With Vim
by runrig (Abbot) on Jan 23, 2008 at 18:34 UTC
    I have something more complicated which outputs to a split window (I like having the output in Vim rather than just piped to less or more in a shell window). I don't know if mine could be simplified, but it does work on Windows...your's does not :-(
Re: Integrating Perldoc With Vim
by shmem (Chancellor) on Jan 24, 2008 at 15:21 UTC
    ++ for that, nice! To include manual pages of modules too:
    " include colon (chr 58) in cword set iskeyword=@,48-58,_,192-255 " look for manual page first, perldoc -q last noremap K :!man <cword> <bar><bar> perldoc <cword> <bar><bar> perldoc +-f <cword> <bar><bar> perldoc -q <cword><cr>

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      A man from ten years into the future applauds you.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

Re: Integrating Perldoc With Vim
by parv (Parson) on Jan 23, 2008 at 21:55 UTC

    That reminds me to fiddle with the iskeyword so that if ('|::) present, could look up the module documentation.

    OTOH, a way similar to runrig's could allow to call perldoc on any number of tokens in a module name. If DBIx::Simple::Examples is written somewhere, then the function could be invoked, with an appropriate number, to invoke perldoc on any of DBIx, DBIx::Simple, and DBIx::Simple::Examples components.

      Here is some code which works with Vim 7 (May 7, 2006); the tokenization is in the last function. Calling Perldoc() on a particular token in the list returned from Tokenize_Perlmod() is left as an exercise for the reader (or, until I find some more time).

      A few minutes later...Now a token is returned given a list index or a pattern as the second optional argument.