sponsor Vim development Vim logo Vim Book Ad

python_pydoc.vim : Python documentation view- and search-tool (uses pydoc)

 script karma  Rating 552/193, Downloaded by 20836  Comments, bugs, improvements  Vim wiki

created by
André Kelpe
 
script type
utility
 
description
This plugin integrates the Python documentation view and search tool pydoc into Vim. It allows you to view the documentation of a Python module or class by typing:

:Pydoc foo.bar.baz (e.g. :Pydoc re.compile)

Or search a word (uses pydoc -k) in the documentation by typing:

:PydocSearch foobar (e.g. :PydocSearch socket)

Vim will split the current window to show the Python documentation found by pydoc (the buffer will be called '__doc__', Pythonic, isn't it ;-) ). The name may cause problems if you have a file with the same name, but usually this should not happen.

pydoc.vim also allows you to view the documentation of the 'word' (see :help word) under the cursor by pressing <Leader>pw or the 'WORD' (see :help WORD) under the cursor by pressing <Leader>pW. This is very useful if you want to jump to the docs of a module or class found by 'PydocSearch' or if you want to see the docs of a module/class in your source code. Additionally K is mapped to show invoke pydoc as well, when you are editing python files.

The script is developed in GitHub at:

http://github.com/fs111/pydoc.vim

If you want to use the script and pydoc is not in your PATH, just put a line like this in your .vimrc:

let g:pydoc_cmd = '/usr/bin/pydoc'

or more portable

let g:pydoc_cmd = 'python -m pydoc'

If you want to open pydoc files in vertical splits or tabs, give the appropriate command in your .vimrc with:

let g:pydoc_open_cmd = 'vsplit'

or

let g:pydoc_open_cmd = 'tabnew'

The script will highlight the search term by default. To disable this behaviour put in your .vimrc:

let g:pydoc_highlight=0

Many, many thanks to all the fine folks that contributed patches so far!
 
install details
In order to install pydoc.vim download it from vim.org or clone the repository on githubi and put it in your .vim/ftplugin directory. pydoc.vim is also fully
compatible with pathogen, so cloning the repository into your bundle directory is also a valid way to install it. (I do this myself. see https://github.com/fs111/dotvim).

If the pydoc-command is not in your PATH, you can put a line like let g:pydoc_cmd = "/usr/bin/pydoc"  in your .vimrc to get it working. The script will highlight the search-term by default. To disable this behaviour put "let g:pydoc_highlight=0" in your .vimrc.

Note: You do not need a python enabled version of vim to use pydoc.vim, everything is done with plain vim scripting and should work on any version >6.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
python_pydoc.vim 2.0 2012-06-19 7.0 André Kelpe pydoc.vim has completely changed: It is now a ftplugin instead of a plugin. It supports the K mapping and has a pathogen friendly repository on github.
pydoc.vim 1.3.6 2011-01-06 6.0 André Kelpe included fix by Thomas Vander Stichele for 'K' handling: https://github.com/fs111/pydoc.vim/commit/14ffe6cdd74e086271e4eb07ba94fe4bd5b94e26
pydoc.vim 1.3.5 2010-11-22 6.0 André Kelpe disabled call to "syn on" in Highlight, since that seems to interfere with NERDTree and also avoid using global variables, as suggested by Jason Mills
pydoc.vim 1.3.3 2010-10-19 6.0 André Kelpe small bugfix: when pydoc.vim is an ftplugin, it gives a warning of redefining a command. From now on it uses command! to avoid this. Thanks to Jason Mills for the patch.
pydoc.vim 1.3.2 2010-06-02 6.0 André Kelpe filter colons out of the search term so that you can use <leader>pW on constructs that end in a colon like "if xxx in sys.modules:" Thanks to Jonathan Hartley for making me aware of that problem.
pydoc.vim 1.3.1 2010-04-11 6.0 André Kelpe new option ('g:pydoc_wh') to control the window height of the pydoc window implemented by Matthias Vogelgesang
pydoc.vim 1.2 2010-03-28 6.0 André Kelpe Lots of changes from Romain Chossart, thanks for that!

- The buffer is not displayed (actually, it is displayed then deleted
quickly) when "no Python doc found". If the buffer was already
displayed, it does a "u" to go back to the last pydoc. A message is
displayed if no corresponding doc is found.
I did that because otherwise, it forces the user to close (or to type
"u") for "uninteresting results".
(implementation is not very pretty, but it does the job).
- The mappings are only set for "python" and "man" filetypes (the
latter being useful for pydoc search inside pydoc)
- Added two mappings : <leader>pk (for pydoc -k word) and <leader>pK
(for pydoc -k WORD)
pydoc.vim 1.1.1 2005-03-06 6.0 André Kelpe The highlighting of the search-term is now optional and can be disabled.
Set in  this in your .vimrc to disable the highlighting:

let g:pydoc_highlight=0

pydoc.vim 1.1 2004-11-15 6.0 André Kelpe This updates adds a simple highlighting to pydoc.vim. All occurrences of your search-term will be highlighted. It uses gui=reverse to be color-scheme independent.
pydoc.vim 1.0.6 2004-10-08 6.0 André Kelpe Version 1.0.5 contains some debug code (call to "input" twice), this versions removes it. Sorry for that.
pydoc.vim 1.0.4 2004-07-16 6.0 André Kelpe Changed the defaut mappings, because many other scripts are using the Function-keys. New mappings are <leader>pw for the current word and <leader>pW for the current Word.
pydoc.vim 1.0.3 2004-02-17 6.0 André Kelpe another small bugfix, I hope the last for today!!
pydoc.vim 1.0.2 2004-02-17 6.0 André Kelpe missing blank in "pydoc -k" fixed
pydoc.vim 1.0.1 2004-02-16 6.0 André Kelpe This version uses the g:pydoc_cmd variable which makes the script usable if the pydoc command is not in  your PATH. This may also work an Windows, but I can't test that. Feedback welcome. Just put a line like

let g:pydoc_cmd = "/usr/bin/pydoc"

into your .vimrc and the scritp will use the specified command.
pydoc.vim 1.0 2004-02-12 6.0 André Kelpe Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github