Vim Tips Wiki
(Added category, some clean up)
m (Some comments merged + code reformated)
Line 15: Line 15:
 
The solution: What if unregistered types would just automatically open up in GVim? Well, they can.. with a little registry trickery.
 
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:
+
===How to Install it: ===
   
Step 1. Create a text file called "vimalways.reg" and paste the below text into it.
+
'''Step 1.''' Create a text file called "vimalways.reg" and paste the below text into it.
 
REGEDIT4
  +
 
[HKEY_CLASSES_ROOT\Unknown\shell]
 
@="vim"
  +
 
[HKEY_CLASSES_ROOT\Unknown\shell\vim]
  +
 
[HKEY_CLASSES_ROOT\Unknown\shell\vim\command]
 
@="\"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 below works fine for a GVim 6.1 default installation.
+
'''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 3:''' Save the file.
   
Step 4: Right-click on the file and select "install". Then you are done!
+
'''Step 4:''' Right-click on the file and select "install". Then you are done!
   
--- vimalways.reg --- cut here ---snip---snip---
 
   
REGEDIT4
 
   
 
'''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).
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell]
 
   
 
'''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.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim]
 
   
 
===Compatibility note: ===
@="Open with &GVim"
 
 
*MS Windows 95 - works OK
 
 
*MS Windows 98 - works OK
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with &GVim\command]
 
 
*MS Windows NT - not sure; if anyone can confirm this please add a note.
 
  +
*MS Windows 2000 - works OK
@="\"C:\\vim\\vim61\\gvim.exe\" \"%1\""
 
  +
*MS Windows XP - should work.
 
---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.
 
 
Compatibility note:
 
 
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 - inserts registry entry OK (right-click the vim.reg file and select "Merge"), but double-click on an unknown-type file does not open file in GVim, so the tip does not work as above. If anyone has corrections for Windows 2000 please add a note.
 
 
MS Windows XP - have not tested. If anyone has tested this and/or has it working please add a note.
 
   
 
}}
 
}}
   
 
== Comments ==
 
== Comments ==
The following works for 2000 and XP:
 
 
 
[HKEY_CLASSES_ROOT\Unknown\shell]
 
@="vim"
 
 
[HKEY_CLASSES_ROOT\Unknown\shell\vim]
 
 
[HKEY_CLASSES_ROOT\Unknown\shell\vim\command]
 
@="\"C:\\Program Files\\vim\\gvim.exe\" \"%1\""
 
 
nicodemus--AT--globalite.com.br
 
, January 3, 2003 16:05
 
----
 
Yes, thanks, I've confirmed the above works on my Win 2k pro.
 
I assume this must be installed as administrator, and affects all users.
 
 
Modified instructions follow for Win2k (and XP -- although I haven't tried it):
 
 
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_CLASSES_ROOT\Unknown\shell]
 
@="vim"
 
 
[HKEY_CLASSES_ROOT\Unknown\shell\vim]
 
 
[HKEY_CLASSES_ROOT\Unknown\shell\vim\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.
 
 
jcline at ieee.org
 
, March 4, 2003 17:19
 
----
 
 
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:
 
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
Right-click on the START button.
 
  +
*Find the folder with your username and open it.
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.
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.
 
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.
Line 128: Line 69:
 
The above instructions maybe impossible to perform if you have insufficient privileges. In that case,
 
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
 
it appears that HKEY_CLASSES_ROOT can be replaced by
HKEY_CURRENT_USER\Software\Classes
+
HKEY_CURRENT_USER\Software\Classes
 
(This works for me on win2k)
 
(This works for me on win2k)
   
Line 135: Line 76:
 
----
 
----
 
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.
 
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
 
  +
--- CUT HERE ---
 
 
[HKEY_CURRENT_USER\Unknown\shell]
Windows Registry Editor Version 5.00
 
 
@="vim"
 
  +
[HKEY_CURRENT_USER\Unknown\shell]
 
 
[HKEY_CURRENT_USER\Unknown\shell\vim]
@="vim"
 
  +
 
[HKEY_CURRENT_USER\Unknown\shell\vim]
+
[HKEY_CURRENT_USER\Unknown\shell\vim\command]
 
@="\"C:\\Program Files\\Vim\\vim70\\gvim.exe\" \"%1\""
 
[HKEY_CURRENT_USER\Unknown\shell\vim\command]
 
@="\"C:\\Program Files\\Vim\\vim70\\gvim.exe\" \"%1\""
 
--- CUT HERE ---
 
 
----
 
----
 
<!-- parsed by vimtips.py in 0.582385 seconds-->
 
<!-- parsed by vimtips.py in 0.582385 seconds-->

Revision as of 18:47, 23 July 2007

Previous TipNext Tip

Tip: #279 - Set Vim as the default editor for unknown file types in Windows

Created: July 9, 2002 14:24 Complexity: intermediate Author: jcline at ieee.org Version: 5.7 Karma: 53/23 Imported from: Tip#279

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.

REGEDIT4

[HKEY_CLASSES_ROOT\Unknown\shell] 
@="vim" 

[HKEY_CLASSES_ROOT\Unknown\shell\vim] 

[HKEY_CLASSES_ROOT\Unknown\shell\vim\command] 
@="\"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 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!


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.

Compatibility note:

  • 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.

Comments

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.

ricardo--AT--darksignals.com , August 22, 2003 10:59


When I use right click, my vimrc file is not executed. How do I solve this?

Anonymous , February 22, 2004 22:58


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

HKEY_CURRENT_USER\Software\Classes 

(This works for me on win2k)

mkaminsky--AT--softhome.net , August 29, 2004 7:22


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 
 
[HKEY_CURRENT_USER\Unknown\shell] 
@="vim" 

[HKEY_CURRENT_USER\Unknown\shell\vim] 

[HKEY_CURRENT_USER\Unknown\shell\vim\command] 
@="\"C:\\Program Files\\Vim\\vim70\\gvim.exe\" \"%1\""