I like having perldoc output to a split window, and I wanted to output module documentation if you were on a 'use Module;' line, so I recently came up with this (my vim-foo could probably be better): function! PerlDoc()
normal yy
let l:this = @
if match(l:this, '^ *\(use\|require\) ') >= 0
exe ':new'
exe ':resize'
let l:this = substitute(l:this, '^ *\(use\|require\) *', "", "")
let l:this = substitute(l:this, ";.*", "", "")
let l:this = substitute(l:this, " .*", "", "")
exe ':0r!perldoc -t ' . l:this
exe ':0'
return
endif
normal yiw
exe ':new'
exe ':resize'
exe ':0r!perldoc -t -f ' . @
exe ':0'
endfunction
"Display docs for built-in functions when cursor is on function name
"or for modules when cursor is on 'use' or 'require' line.
map ,h :call PerlDoc()<CR>:set nomod<CR>:set filetype=man<CR>:echo "pe
+rldoc"<CR>
Updated. (I knew nothing about Vim programming before I started this...it took a couple of hours to come up with the first version of this, so comments, etc., welcome).
Update: Added set nomod.
Update: Added filetype, C-M=>CR, echo message
Update: added -t
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|