Vim logo vim online Vim Book Ad

 Tip #279: On Windows, make GVim the default action for double-click with "unknown file types"

 tip karma   Rating 23/11, Viewed by 898 

created:   July 9, 2002 14:24      complexity:   intermediate
author:   jcline at ieee.org      as of Vim:   5.7

I find myself installing the following registry modification for all my PC's now (even other people's PC's).  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 editted 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.

How to Install it:

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

Step 2.  Important NOTE: You will have to edit the pathname to correspond to the pathname of your GVim.exe.  The text below 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!


------ vimalways.reg  ------- cut here ------snip---snip---
REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim;]
@="Open with &GVim;"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim;\command]
@="\"C:\\vim\\vim61\\gvim.exe\" \"%1\""

----end of file---- cut here----- snip---snip----

Note 1.  This can't be de-installed 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.



Ok, thanks for playing!  
And thanks to the author(s) of Vim and GVim.
If it weren't for them, I'd still be using elvis or stevie!

 rate this tip  Life Changing Helpful Unfulfilling 

<<all the right moves | Integration with PyUnit testing framework >>

Additional Notes

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo