Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #556 - Access Python Help

Created: September 11, 2003 16:33 Complexity: basic Author: Fritz Cizmarov 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.

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.


Advertisement