sponsor Vim development Vim logo Vim Book Ad

VPE - Vim Python Extensions : Extension for Vim scripting using Python 3

 script karma  Rating 4/1, Downloaded by 65  Comments, bugs, improvements  Vim wiki

created by
Paul Ollis
script type

  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

Quick start

  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
    standard python-buffer.

  - 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
      a clone.


  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
install details
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.

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
vim-vpe-0.2.zip 0.2 2020-10-27 8.0 Paul Ollis Documentation improvements (still needs work).
Some internal code refactoring.
Improved logging of run-time errors (to log buffer).
Syntax class:
  - Added link_to argument to group method.
  - Prevent annoying warning message.
Buffer class:
  - 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.
vim-vpe.zip 0.1 2020-10-02 8.0 Paul Ollis Initial upload
ip used for rating:

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.