The Python file type plug-in for Vim helps you while developing in Python by providing the following features:
gfto jump to imported files (searches the Python path).
from(automatic completion can be disabled if you find it is too intrusive).
os.it would complete
os.path(and others). Be aware that this imports modules to perform introspection and assumes that importing a module does not have serious side effects (although it might, however it shouldn’t).
from <module> import <variable>line. (this is not enabled by default because of the side effect issue mentioned above).
To use the plug-in, simply drop the files into your Vim profile directory (usually this is
~/.vim on UNIX and
%USERPROFILE%\vimfiles on Windows), restart Vim and execute the command
:helptags ~/.vim/doc (use
:helptags ~\vimfiles\doc instead on Windows).
To use the syntax check, please make sure pyflakes is installed. It can be found in most Linux distributions, e.g. on Debian/Ubuntu Linux it can be installed using the following command:
$ sudo apt-get install pyflakes
To enable folds for classes and functions defined without leading whitespace, make sure your Python syntax file uses a match rather than a keyword statement for the def and class keywords.
Change the line to say something like:
:syntax match [group] "\<\%(def\|class\)\>" [options]
I can recommend you Dmitry Vasiliev’s adaptation of the default Python syntax file. In this file you will need to replace the following line:
:syntax keyword pythonStatement def class nextgroup=pythonFunction skipwhite
:syntax match pythonStatement "\<\%(def\|class\)\>" nextgroup=pythonFunction skipwhite
All options are enabled by default. To disable an option do:
:let g:OPTION_NAME = 0
Enables syntax based folding for classes, functions and comments.
Enables syntax based folding for strings that span multiple lines.
To display the docstring of a class/function in the fold text.
To display the decorators in the fold text. Currently arguments to decorators are not shown.
This is a dictionary mapping decorator names to short labels. By default it is empty.
Enables automatic syntax checking when saving Python buffers. This uses pyflakes when available but falls back on the standard Python compiler for syntax checking.
Controls automatic completion of module names after typing
from<Space>. Enabled by default.
Controls automatic completion of variables after typing a dot or
from <module> import<Space>. Disabled by default.
If you have questions, bug reports, suggestions, etc. you can contact Bart at email@example.com or Peter at firstname.lastname@example.org. The latest version is available at http://peterodding.com/code/vim/python-ftplugin and https://github.com/tarmack/vim-python-ftplugin.
This software is licensed under the MIT license.
© 2013 Peter Odding <email@example.com> and Bart Kroon <firstname.lastname@example.org>.
Last updated Thu May 23 22:10:52 UTC 2013.