Context menu issues with gVim in Windows 7 x64

Over the years I’ve developed a serious vi editor habit (mostly from my days working as a system administrator). I use it for coding in PHP, c, and perl because it is convenient and lightweight. Since gVim has been available for Windows, I have never had any issues running it on my home computer and that Edit with VIM right-click context menu item became my best friend. Until now that is. Windows 7 64-bit will run gVim as a 32bit application, but the context menu shortcuts are gone. Here is my workaround.

I found that there are two ways of doing this. One involves messing around with the registry (see Disclaimer), the other involves creating a shortcut.

contextmenu

If you want to have the same context menu functionality you got from gVim in 32-bit Windows you’ll need to make the following changes to the [HKEY_CLASSES_ROOT\*\shell\] key in the registry:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Edit with Vim]

[HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
@=”C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe \”%1\”

If you are lazy you can simply download my registry export file by clicking here and merge it into your registry (see Disclaimer).

Don’t want to make changes to the registry? Then here is the alternative:

The Send To context menu is pretty customizable in both VISTA and Windows 7. You can add as many shortcuts to this context menu as you want simply by dragging and dropping them into this folder:

C:\Users\<user name>\AppData\roaming\microsoft\windows\SendTo

sent_tomenu

So simply adding a gVim shortcut here and voila, an albeit slightly less convenient gVim shortcut now exists on the right-click context menu.

37 Responses So Far... Leave a Reply:

  1. Ron says:

    Thanx for the fix!!

  2. TechFan says:

    Thanks for the tips. I got gVim working this way. . .I did discover that either of these two methods open very slowly if they path is a UNC path to the file. If I map a drive it is fine though. \\server\share\file opens in almost a minute in comparison to a couple seconds with a mapped drive. . .I didn’t have that issue on 32-bit vista (before this upgrade to Win7)??

  3. Andy says:

    Thank you!! I was really annoyed after installing Vim on my new Win7 install and the Edit with Vim option wasn’t there. Much much better now!

  4. @noter
    I tried this package, but it wouldn’t install the context menu item “Edit with Vim” in Windows 7 x64

  5. Seth says:

    And another thank you!

  6. [...] Context menu issues with gVim in Windows 7 x64 [...]

  7. Alkor Arman says:

    Thank-you very much! I really misssed this after installing Windows 7. I can’t edit without vi.

  8. Nate says:

    Anyway to get back the select two items and right-click so you get ‘Diff with Vim’?

  9. @Nate
    I use a program called ExamDiff (just google it) for the diff functionality, but it’s a couple of extra clicks because I use it through the Send To Menu. Basically the program is is an executable file you can put anywhere. I put it in C:\ root, then I create a shortcut to ExamDiff.exe in my Send To folder (C:\Users\\AppData\roaming\microsoft\windows\SendTo). Now I can simply select two files, right-click->Send To->ExamDiff and voila I have the two files in ExamDiff highlighting the differences btw. the two. I’ll look at the VIM Diff functionality as a weekend project when I’m done with finals :)

  10. Joe Zamora says:

    Don’t forget the icon!

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\*\shell\Edit with Vim]
    “icon”=”C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe”

    [HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
    @=”C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe \”%1\”"

  11. alice says:

    This was really, really helpful. Thank you so much!

  12. Bill H says:

    Thanks for the fix. I was really starting to miss my “Edit With Vim…” entry!

  13. AndreasK says:

    Hi,

    klasse, das habe ich bei Win7 vermisst, danke für die .reg Datei !

    Lieben Gruss
    Andreas

  14. MikeM says:

    merci beaucoup!

  15. Bob says:

    I can’t seem to get the 64bit version of gvim (from Google Code) working even after modifying for ‘Program Files’ instead of ‘Program Files (x86)’. Getting error:

    “This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.”

    And FWIW I think the registry setting in the article is missing a trailing doublequote.

  16. @Bob
    Bob,

    This article uses the 32bit version of gVim, not the 64bit version. I couldn’t get that to work either. The article illustrates how to get the context menu “edit with gVim” entry to work after installing the 32bit version of gVim on Windows 7 x64. The issue is that in Windows 7 the context menu change isn’t applied during the installation of the program.

    As far as the registry change goes, I exported it from my registry so I think the quotes are correct, however, please note the disclaimer whenever making changes to your computer.

    Cheers,
    David

  17. Bob says:

    @David

    Good to know, thanks. I had no idea how much I relied on the “Edit with Vim” til I switched to a Win7 machine.

  18. Bob says:

    One last note – this is likely obvious to many but – while I was resigning myself to having to use SendTo I noticed that …\AppData… is a hidden folder in Win7. You’ll probably have to use “Organize”/”Folder and Search Options”/”View”/”Show hidden” to make it visible.

  19. CJ Gaconnet says:

    I thank you tremendously.

  20. tsohr says:

    Thanks!! :)

  21. martin says:

    thanks but the 64bit version works on my pc :D

  22. Yosi says:

    Will this also restore the “Edit with existing Vim” functionality?

  23. The Duke says:

    An alternative, which also restores the “Edit with existing Vim” functionality, is to download the x64 build of vim from http://code.google.com/p/vim-win3264/wiki/Win64Binaries

    This is linked to on the vim download page for windows at http://www.vim.org/download.php#pc

  24. Roger says:

    Your quick link worked perfectly. Thank you much.

  25. GC says:

    Great, thank you :-)

    A small precision for non-specialists of registry:
    the [HKEY_CLASSES_ROOT\*\shell\Edit with Vim] and [HKEY_CLASSES_ROOT\*\shell\Edit with Vim\Command] should be created by right click > New > Key
    The default value is then set to ”C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe \”%1\””

  26. GC says:

    Ooops I meant “C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe” “%1″

  27. KWM says:

    Thanks! Also, I found that I couldn’t get gvim to toggle between insert and move mode using the trusty esc key. I added a toggle command to the _vimrc (set im!), and strangely enough, the functionality is there. I need my vim!

    Vi’ing since ’97

  28. sibsib says:

    Hi,

    Thanks for the tip, I’magain an happy vimmer :-)

  29. Arrow says:

    Thanks.

  30. Jose says:

    Dude! Thanks so much! I was wondering why I did not have this “Edit with Vim” in my context menu. Total lifesaver.

  31. meitham says:

    I set my vim to run as a server with all new files opened in new tabs using –remote-tab-silent

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\*\shell\Edit with Vim]
    “icon”=”C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe”

    [HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
    @=”\”C:\\Program Files (x86)\\Vim\\vim72\\gvim.exe\” –servername GVIM –remote-tab-silent \”%1\”"

    if you copy and paste make sure to fix the double quotation symbol, otherwise windows will get confused.

  32. JR says:

    Thanks for this – very useful as I just installed 64bit Windows 7 and was missing the Edit with Vim option.

  33. guest says:

    Thank you!

    Seems only we sys admins like vi :-)