Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 279 Printable Monobook Previous Next

created July 9, 2002 · complexity intermediate · author jcline · version 5.7

I find myself installing the following registry modification for all my PCs now (even other people's PCs). It applies to Microsoft Windows machines only. The following is also for Windows 9x. NT or XP or 2000 may require modifications (which I don't care to understand!).

The problem: You double-click on a file that doesn't have a registered type and that pesky "What program should I use?" dialog pops up. Even worse, depending on the installation, the gvim icon may not be listed, and one has to browse to the executable. and then the type becomes forever bonded to being edited with gvim (if that box is checked). The standard Vim 6.1 installation does include a "right click to edit" menu item for all files, but a double-click is so much faster!

The solution: What if unregistered types would just automatically open up in gvim? Well, they can. with a little registry trickery.

WARNING: Editing your Windows registry may cause unintended side effects that render your system inoperable. Although this tip has worked in the past for some people, there is no guarantee that it will work for you. Use with caution, and at your own risk.

How to Install itEdit

Step 1. Create a text file called "vimalways.reg" and paste the below text into it.

@="\"C:\\Vim\\vim61\\gvim.exe\" \"%1\""

Step 2. Important NOTE: You will have to edit the pathname to correspond to the pathname of your gvim.exe. The text above works fine for a gvim 6.1 default installation.

Step 3: Save the file.

Step 4: Right-click on the file and select "install". Then you are done!

Note 1. This can't be uninstalled automatically, and if you want to remove it, you'll have to edit the registry by hand (annoying, but easy).

Note 2. Keep this file around, so when you upgrade your gvim, all you have to do is modify the pathname (to say, for example, vim62) and then install it again.

Note 3. A similar but unrelated task is to open all files without file-extension in gvim by default.

Compatibility noteEdit

  • MS Windows 95 - works OK
  • MS Windows 98 - works OK
  • MS Windows NT - not sure; if anyone can confirm this please add a note.
  • MS Windows 2000 - works OK
  • MS Windows XP - should work.
  • MS Windows 7 - works, with data added manually in regedit (change existing ...\shell key value from "openas" to "vim")


What I do on any machine I'm working on, and should work in any of the Windows OSs, is add a shortcut to Gvim in my SendTo folder. This can be done by:

  • Right-click on the START button.
  • Click Explore All Users
  • Find the folder with your username and open it.
  • Find the Send To folder, and copy a shortcut to Gvim in there.

Now, if I right-click on any file, I can choose to send it to GVim by using the Gvim short-cut on the Send-to list.

The above instructions maybe impossible to perform if you have insufficient privileges. In that case, it appears that HKEY_CLASSES_ROOT can be replaced by


(This works for me on win2k)

I had a MERGE option when right clicking on the .reg file. I also couldn't get it to import until I added the top line below. Thought I'd share the modification I had to make. Thanks for the tip.

Windows Registry Editor Version 5.00



@="\"C:\\Program Files\\Vim\\vim70\\gvim.exe\" \"%1\""

To set Vim as the editor for a specific file type on Windows XP:

Windows Explorer
folder options
file types
select a type, for example HTML
click ADVANCED button (if it is visible)
select Edit action on left, and click EDIT button on right
click Browse ... button, and then select Vim
click OK a few times

If you find "Windows Script Host" taking over your editing privileges (or Open..) for Javascript files, you can remove Windows Script Host, which is a nasty vector for VBS-borne viruses anyway.

Search your C: drive for wscript.exe and either delete it or (possibly) rename it. (Don't know if renaming it works.) A reboot may be required.

On my system, though, I couldn't find it, but adding this line to the above registry file did the trick:


Note that this deletes that key. You might need to reassociate .js. Also, if you're trying to edit .js files on a network drive and are getting warnings, follow instructions here: In that case, I also had to click Advanced (for the first option) and add my network drive letter (ie F:), which automatically added file:// to my list.

Windows Script Host can be very useful. I certainly would never recommend something as drastic as renaming the system file wscript.exe to disable scripting in Windows. If you're worried about viruses, just don't run .js or .vbs files from unknown sources without examining them in an editor first. Even hijacking the "Open" function is questionable, it makes it more difficult to run a script from the Windows command-line.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.