python.vim - Vim file type plug-in for the Python programming language

The Python file type plug-in for Vim helps you while developing in Python by providing the following features:

Experimental features:

# Installation

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

with:

:syntax match pythonStatement "\<\%(def\|class\)\>" nextgroup=pythonFunction skipwhite

# Options

All options are enabled by default. To disable an option do:

:let g:OPTION_NAME = 0

# The g:python_syntax_fold option

Enables syntax based folding for classes, functions and comments.

# The g:python_fold_strings option

Enables syntax based folding for strings that span multiple lines.

# The g:python_docstring_in_foldtext option

To display the docstring of a class/function in the fold text.

# The g:python_decorators_in_foldtext option

To display the decorators in the fold text. Currently arguments to decorators are not shown.

# The g:python_decorator_labels option

This is a dictionary mapping decorator names to short labels. By default it is empty.

# The g:python_check_syntax option

Enables automatic syntax checking when saving Python buffers. This uses pyflakes when available but falls back on the standard Python compiler for syntax checking.

# The g:python_auto_complete_modules option

Controls automatic completion of module names after typing import<Space> or from<Space>. Enabled by default.

# The g:python_auto_complete_variables option

Controls automatic completion of variables after typing a dot or from <module> import<Space>. Disabled by default.

# Contact

If you have questions, bug reports, suggestions, etc. you can contact Bart at bart@tarmack.eu or Peter at peter@peterodding.com. The latest version is available at http://peterodding.com/code/vim/python-ftplugin and https://github.com/tarmack/vim-python-ftplugin.

# License

This software is licensed under the MIT license.
© 2013 Peter Odding <peter@peterodding.com> and Bart Kroon <bart@tarmack.eu>.

Last updated Thu May 23 22:10:52 UTC 2013.