-
Notifications
You must be signed in to change notification settings - Fork 5
Plugins
Brandon R. Stoner edited this page Jun 13, 2013
·
1 revision
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 nowinsert_leave
-
TabLeave
is nowtab_leave
-
WinEnter
is nowwin_enter
-
FocusGained
is nowfocus_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.