Skip to content

5. Command Reference

Andrew Hallagan edited this page Apr 15, 2015 · 1 revision

ListVimHooks

The :ListVimHooks command takes zero arguments. It opens a new unmodifiable buffer in a horizontal split which lists all of the VimHook script files the plugin has found after scanning the current working directory as well as the ~/.vimhooks/ directory. The enabled hook scripts are listed before the disabled ones. Helpfully, within each of these groupings, the relative order of the hook scripts matches their order of execution.

There are two sections in this buffer: the Mappings section which shows a "cheat sheet" of the buffer-local mappings and the Hooks section which, for each VimHook script, shows a checkbox indicating the enabled/disabled state of the script (checked means enabled), the matching suffix (where * represents a UNIX-style blob), the autocommand event which triggers the script, and the path to the script. The x mapping is particularly useful as it allows you to quickly toggle on and off individual VimHook scripts as you move between projects that require different hooks.

Pressing s, i, o, or <CR> will open the hook file for editing in one way or another. If you make changes to a hook file and save it, the plugin will automatically pick up those changes. Isn't that nice? It does this by listening for BufWritePost events on *vimhook*-patterned filenames and re-running :FindHookFiles for you.

ListVimHooks GIF

Note: this gif is slightly out of date. The :ListVimHooks command has since been modified to always list active VimHook scripts first at the top of the Hooks section before listing the inactive ones.

The buffer-local mappings are inspired from NERDTree:

  • x Toggles the enabled/disabled state of a VimHook script (this only has an effect when on one of the lines in the "Hooks" section.
  • s Opens a VimHook script in a vertical split
  • i Opens a VimHook script in a horizontal split
  • o, Opens a VimHook script in the previous window. (If not possible, it will open in a vertical split.)
  • <CR>, Opens a VimHook script in the current window

FindHookFiles

The :FindHookFiles command re-runs the same initializing logic VimHooks runs when you start Vim with the plugin installed. It will "forget" any VimHook scripts it may have previously found and re-scan the current working directory as well as the ~/.vimhooks/ directory. Use this command if you have created a new VimHook script and want to start using it without closing and re-opening your entire Vim session.

ExecuteHookFiles

The :ExecuteHookFiles command takes a single argument which is the name of a Vim autocmd you would like to manually "trigger." The event name can be tab-completed. For example, if you would like to verify the VimHook scripts listening for the VimEnter event are functioning correctly you can manually fire them off by running :ExecuteHookFiles VimEnter.

StopExecutingHooks

The :StopExecutingHooks command will temporarily disable triggering of all VimHook scripts.

StartExecutingHooks

The :StartExecutingHooks command turns VimHook script triggering back on.

Clone this wiki locally