Skip to content
Brandon R. Stoner edited this page Jun 13, 2013 · 1 revision

Vimpy Plugins

Vimpy provides the concept of AutoCommands through a type of object called a Plugin. This object allows you to handle autocommand-like functionality through a more Pythonic event handling interface. For instance, you could bind to the VimEnter autocommand with the following plugin:

    from vimpy import Plugin

    class HelloWorldPlugin(Plugin):
        def vim_enter(self):
            print('Hello, world.')

Every autocommand has been exposed in this same way. The name of an plugin function is defined by replacing every uppercase letter in the normal Vim autocommand's name with an underscore, and converting the entire name to lowercase. Some examples are:

  • InsertLeave is now insert_leave
  • TabLeave is now tab_leave
  • WinEnter is now win_enter
  • FocusGained is now focus_gained

If this is still a bit confusing (and it might be at first!) then you can always refer to the source code to see what function names will be used for your autocommands.

Clone this wiki locally