VPE - Vim Python Extensions : Extension for Vim scripting using Python 3
| script karma
Downloaded by 65
Comments, bugs, improvements
script versions (upload new version)
VPE adds to Vim’s built-in support for Python scripting. This is a brief list
of VPE’s features.
- A Vim class that provides an enhanced, drop-in replacement for the
standard python-vim module.
- Classes Window, Buffer, TabPage are enhanced wrappers around the
standard vim versions.
- 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.
- Pythonic support for channels.
- Logging to a buffer. Useful when developing and debugging plug-ins.
When active in a window, the window automatically scrolls to show new
The quickest way to start using VPE is to import the vim object:
from vpe import vim
The vim object is an instance of the Vim class and is intended to be a drop
in replacement for Vim’s standard python-vim module, but with a number of
- 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 messages.
- 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 Buffer instance in place of Vim’s
- The Vim registers are available using the registers attribute.
- When errors occur a VimError is raised, which provides a better
breakdown of the error. This is a subclass of vim.error so existing
code that catches vim.error still works.
The above just scratches the surface, see :help vpe.txt for detailed
documentation or https://vim-vpe.readthedocs.io/en/latest/.
Please treat the examples as demo, minimally tested code.
The examples provided with VPE are:
vpe_filenav - start with, ':runtime examples/vpe_filenav.vim'
A very simple file explorer that can be used to open files.
vpe_bufnav - start with, ':runtime examples/vpe_bufnav.vim'
An explorer for buffers. This is heavily inspired by Jeff
Lanzarotta's excellent vimscript #42, but it does not attempt to be
VPE requires a minimum of Vim 8.0.0700 and Python 3.6.
VPE has not been been tested on Windows (yet) or Mac. If you manage to test
it before me, let me know how it goes.
I consider the code to be quite stable. It passes a reasonably
comprehensive set of tests and I use VPE daily for my standard Vim
|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.
$ 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 source code is at https://github.com/paul-ollis/vim-vpe.git. You can clone
this into ~/.vim/pack, but that will, currently, not include the Vim help file.
Click on the package to download.
ip used for rating: 18.104.22.168
||Documentation improvements (still needs work).
Some internal code refactoring.
Improved logging of run-time errors (to log buffer).
- Added link_to argument to group method.
- Prevent annoying warning message.
- Added new properties: type, location, long_display_name,
short_display_name, short_description, bufnr, changed, changedtick,
lastused, lnum, linecount, loaded, variables, windows and popups.
- Added goto_active_window method.
Started adding some examples as a supplement to the documentation.
The HTML help is now available on readthdocs.