Add Vim to the Windows Explorer context menu
From Vim Tips Wiki
created 2004 · complexity basic · author Mark Fernandes · version 5.7
Do you wish you had your own Vim settings for a file appear automatically when you right click in Windows Explorer? If so then read on, following these steps sequentially:
Create a template file where the last few lines control Vim. Example contents:
--------------------------------End of Text---------------------------------- The line below controls Vim, which you can get free from: http://www.vim.org/ vim:tw=80:ai:ft=txt:norl:
Call the above sample template file GVIM.vtd and save it in the "C:\Windows\ShellNew\" directory. You may use another extension, but I played it safe and used one that wasn't being used on my system. Moreover, I did not change the default location of Windows installation, but you may need to do so if your system does not match mine.
Open Explorer and click on Tools->Folder Options. In the dialog box that appears, click on File Types and then scroll the file types until you reach VTD. Click on the file extension VTD and click on Change; now associate gvim.exe with this file extension.
Click Start, Run and enter
In the registry, scroll HKEY_CLASSES_ROOT until you get to Vim.Application
- Add a key called "shell".
- In [HKEY_CLASSES_ROOT\Vim.Application\shell] and a key called "open".
- In [HKEY_CLASSES_ROOT\Vim.Application\shell\open] and a key called "command".
- Double click the "(Default)" value of "command" and change it to point to the location of gvim.exe on your system. I entered the following in the text field "Value data"
In regedit, find HKEY_CLASSES_ROOT and scroll to ".vtd", then change the string value (Default) to
Click on [HKEY_CLASSES_ROOT\.vtd] and add a key called "ShellNew".
Click on "ShellNew" and add a string value called "FileName". Double click on "FileName" and enter
In Windows Explorer, navigate to any directory. Right click the pane displaying the files, to see "Vim" as one of your options. When you choose Vim, you will create a file called "New Vim.vtd" in that directory. When you open "New Vim.vtd" you should see the above sample text and Vim uses the settings used in the last line of the file.
Any changes made to the original template in C:\Windows\ShellNew appear in new files that you create.
The installers don't seem to create the context menu entries on 64-bit Windows XP (and possibly other 64-bit systems. Maybe we should resurrect this tip? Or maybe we have another tip on this? --Fritzophrenic 16:12, January 3, 2012 (UTC)
You can also do without the template file.
In this case, when right clicking on New->vim an empty file called "New Vim.vtd" is created which inherits all the setting defined in vimrc. I find this more useful and it also simplifies the instructions.
The only changes to the instructions in this tip are
- Skip the whole creation of the file gvim.vtd
- Change the instructions:
- Click on "ShellNew" and add a string value called "FileName". Double click on "FileName" and enter
- Click on "ShellNew" and add a string value called "NullFile".