Thursday, October 27, 2011

Add "Edit with Vim" item to context-menu in Windows for Vim

This post shows how to add "Edit with Vim" and "Tab Edit with Vim" items to context menu (pop out when you right click a file) in Windows.

Run regedit.exe, go to HKEY_LOCAL_MACHINE/SOFTWARE/Classes/*/shell/

  1. Create new key "Tab Edit with &Vim" (Right click parent entry -> New -> Key)
  2. Create new key "Edit with Vim"
  3. Create new key "command" under "Tab Edit with &Vim"
  4. Edit the entry with name "(Default)", change its data to
    <vim_dir>\gvim.exe" -p --remote-tab-silent "%1" "%*"
  5. Create new key "command" under "Edit with Vim".
  6. Edit the entry with name "(Default)", change its data to
    <vim_dir>\gvim.exe "%1"

It seems that latest versions of vim automatically create the registry entry:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim and the data of entry path points to the vim executable.
  • HKEY_CLASSES_ROOT\*\shellex\ContextmenuHandlers\gvim. Data of the entry "(Default)" is the CLSID (51EEE242-AD87-11d3-9C1E-0090278BBD99).
    You can delete this entry because we have already added menu item "Edit with Vim".
  • HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\edit\command. Data of the entry "(Default)" is "<vim_dir>\gvim.exe" "%1"
  • HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}
    It has a key named InProcServer32. The data of "(Default)" is <vim_dir>\gvimext.dll
  • Some other keys