Access Python Help
From Vim Tips Wiki
Tip 556 • Previous Tip • Next Tip
Created: September 11, 2003 Complexity: basic Author: Fritz Cizmarov Minimum version: 6.0 Karma: 4/4 Imported from: Tip#556
Add the following two lines to your ~/.vim/ftplugin/python.vim. Then open any Python script. You can place the cursor on a keyword, and press F2 to view Help.
map <F2> :exec "!xterm -e 'pydoc ".expand("<cword>")."'"<CR><CR>
imap <F2> <ESC>:exec "!xterm -e 'pydoc ".expand("<cword>")."'"<CR><CR>i
If it does not work, be sure that xterm and pydoc exist. To see the return message in Vim, delete the last <CR> in the lines.
[edit] Comments
You can open the doc inside Vim like this:
function! ShowDoc(name)
enew
execute "read !pydoc " . a:name
setlocal nomodifiable
setlocal nomodified
set filetype=man
normal 1G
endfunction
map <buffer> <silent> +m :call ShowDoc("<C-R><C-W>")<CR>
This is not tested, but I use something very similar for Perl.
Categories: Review | VimTip | Python
