-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This is a Vim plugin that lets you automatically execute arbitrary shell
scripts after specific autocmd events are fired while editing certain files.
It does this by looking for specially-named scripts in your current working
directory (as well as ~/.vimhooks/) that have names like
.bufwritepost.vimhook.rb or .cursorhold.vimhook.sh and executes those
scripts whenever – in this example – Vim fires the BufWritePost
and CursorHold autocmd events, respectively.
VimHook scripts, which I refer to as "hook scripts," or just "hooks"
throughout this document, can live at the project level or at a global level
in ~/.vimhooks/. Hooks can be synchronous (the default) or
asynchronous (in a fire-and-forget sort of way). The autocmd triggers
can be debounced so hooks are only executed once within a specified
window of time. The stdout produced by hook scripts can be buffered into a
split window that refreshes automatically every time the hook is executed.
Hooks report stderr when they
exit with a non-zero exit code.1 Finally, the :ListVimHooks command
provides a listing of all enabled and disabled hook scripts available in a
particular session. They are listed in the order they would (synchronously)
execute and can be toggled on and off interactively. You can make edits to
hook scripts on the fly and the changes will be reflected the next time they
are run.
1 The exception is that asynchronous hooks do not report stdout or stderr. (See the VimHook Options section for more details).