The Vim Python Extensions (VPE)¶
VPE adds to Vim’s built-in support for Python scripting with the following aims.
Ability to write more Pythonic code.
Provide a toolkit of additional classes and functions to support complex plug-ins.
Be extremely compatible with existing Vim Python scripts.
VPE requires a minimum of Vim 8.0.0700 and Python 3.6.
VPE has not been tested on Windows.
The VPE directory tree is structured as a package with a single plugin. Assuming your Vim files are in the “~/.vim” directory, add a “pack” sub-directory and install VPE into the “~/.vim/pack” directory. One way to do this is by simply cloning the VPE repository.
$ cd ~/.vim/pack $ git clone https://github.com/paul-ollis/vim-vpe.git
or just unzip vim-vpe.zip.
$ cd ~/.vim/pack $ unzip vim-vpe.zip
The package includes a “vim-vpe/start/vpe/plugin/vpe.vim” startup script that updates the Python path so that the vpe package can be imported.
The quickest way to start using VPE is to import the
from vpe import vim
Most of Vim’s functions appear as members, for example:
vim.cursor(4, 10) # Position cursor at row 4, column 10. m = vim.execute('messages') # Get all the recent Vim messagse.
The attributes buffers, current, options, tabpages, vars, vvars and windows provide enhanced access to the corresponding Vim objects. For example vim.current.buffer provides a
Bufferinstance in place of Vim’s standard python-buffer.
The Vim registers are available using the
This is a brief list of VPE’s features.
Support for cleanly invoking Python functions for keyboard mappings.
Pythonic support for using popup-windows. (Requires Vim 8.2.)
Pythonic support for using timers.
Pythonic support for autocommands that invoke Python functions.
Python support for channels.
Logging to a buffer. Useful when developing and debugging plug-ins.