created 2005 · complexity intermediate · author corp-mule · version 6.0
It is possible to configure Windows systems so that Windows Explorer includes an "Edit with Vim" item on the right-click context menu (see here). This tip shows how to add an "Open Vim here" item when a directory is right clicked, on a 32-bit Windows system. When configured, you can use Windows Explorer to right click a directory, select "Open Vim here", then use the "Explore" mode of Vim to navigate the directory and edit any files it contains.
To do this, we will use the same registry location as used for Windows file associations to create a specialized custom action available for Folders.
Original tip[]
REGEDIT4 [HKEY_CLASSES_ROOT\Folder\shell\VimHere] @="Open Vim here" [HKEY_CLASSES_ROOT\Folder\shell\VimHere\command] @="C:\\Program Files\\Vim\\vim72\\gvim.exe ."
This command will open vim in Explore mode:
C:\Program Files (x86)\Vim\vim73\gvim.exe "%1"
This command will open a new buffer with path set:
C:\Program Files (x86)\Vim\vim73\gvim.exe --cmd "new|on" "%1"
From 200911[]
Find or create registry key HKEY_CLASSES_ROOT\Folder\shell\Open Vim here\command
and change the default value to (using the correct path for your system):
"C:\\Program Files\\Vim\\vim72\\gvim.exe" "%1"
The "Open Vim here" is any text that will be shown on the context menu when a directory is right clicked in Windows Explorer.
The quotes in "%1"
are required to work with a directory with a space in its name. Alternatively, just use .
as shown above.
The following could be saved in a .reg file to be imported for a slightly different implementation to achieve the same result. Because this uses HKEY_CURRENT_USER
the user does not need administrative privileges.
REGEDIT4 [HKEY_CURRENT_USER\Software\Classes\Folder\shell\Open Vim here\command] @="\"C:\\Program Files\\Vim\\vim72\\gvim.exe\" ."
Comments[]
TO DO
- Work out what the difference between the procedures is, and probably merge them.