Vim Tips Wiki
Advertisement
Tip 556 Printable Monobook Previous Next

created September 11, 2003 · complexity basic · author Fritz Cizmarov · version 6.0


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