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*shellEdit with Vim]

[HKEY_CLASSES_ROOT*shellEdit with Vimcommand]
@=”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>AppDataroamingmicrosoftwindowsSendTo

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.
UPDATE: As mentioned by several users via comments (thank you!), it looks like the “Edit with Vim” context menu option in Windows7 x64 is now going to be installed by default with the GVIM 7.3 package. I want to take this opportunity to thank to everyone for their kind words and helpful suggestions.


Posted

in

by

Comments

51 responses to “Context menu issues with gVim in Windows 7 x64”

  1. Ron Avatar

    Thanx for the fix!!

  2. TechFan Avatar
    TechFan

    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. \serversharefile 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 Avatar

    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. David Vielmetter Avatar

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

  5. Seth Avatar
    Seth

    And another thank you!

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

  7. Alkor Arman Avatar
    Alkor Arman

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

  8. Nate Avatar
    Nate

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

  9. David Vielmetter Avatar

    @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:UsersAppDataroamingmicrosoftwindowsSendTo). 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 Avatar
    Joe Zamora

    Don’t forget the icon!

    Windows Registry Editor Version 5.00

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

    [HKEY_CLASSES_ROOT*shellEdit with Vimcommand]
    @=”C:\Program Files (x86)\Vim\vim72\gvim.exe “%1″”

  11. alice Avatar

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

  12. Bill H Avatar
    Bill H

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

  13. AndreasK Avatar
    AndreasK

    Hi,

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

    Lieben Gruss
    Andreas

  14. MikeM Avatar
    MikeM

    merci beaucoup!

  15. Bob Avatar
    Bob

    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. David Vielmetter Avatar

    @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 Avatar
    Bob

    @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 Avatar
    Bob

    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 Avatar
    CJ Gaconnet

    I thank you tremendously.

  20. tsohr Avatar
    tsohr

    Thanks!! ๐Ÿ™‚

  21. martin Avatar
    martin

    thanks but the 64bit version works on my pc ๐Ÿ˜€

  22. Yosi Avatar
    Yosi

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

  23. The Duke Avatar
    The Duke

    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. Michael McNamara Avatar

    Thanks for the help!

  25. luis Avatar
    luis

    Amen ๐Ÿ˜€

  26. Roger Avatar
    Roger

    Your quick link worked perfectly. Thank you much.

  27. GC Avatar
    GC

    Great, thank you ๐Ÿ™‚

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

  28. GC Avatar
    GC

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

  29. KWM Avatar
    KWM

    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

  30. sibsib Avatar
    sibsib

    Hi,

    Thanks for the tip, I’magain an happy vimmer ๐Ÿ™‚

  31. Arrow Avatar
    Arrow

    Thanks.

  32. Jose Avatar

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

  33. meitham Avatar

    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*shellEdit with Vim]
    “icon”=”C:\Program Files (x86)\Vim\vim72\gvim.exe”

    [HKEY_CLASSES_ROOT*shellEdit with Vimcommand]
    @=””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.

  34. JR Avatar

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

  35. guest Avatar
    guest

    Thank you!

    Seems only we sys admins like vi ๐Ÿ™‚

  36. Lessan Avatar
    Lessan

    Thanks for the tip, was looking for that menu entry!

  37. Dan Avatar

    Excellent tip!! Thanks for sharing.

  38. Nachum Kanovsky Avatar

    Try my gvim x64 installer and directions for building:
    http://ionipti.blogspot.com/2010/04/build-gvim-72-x64-and-create-installer.html
    Solves all the usual problems in x64.

    1. Sascha Joswig Avatar
      Sascha Joswig

      Hi Nachum,

      would be great if you could integrate a silent switch as well. That would make things perfect.

      Sascha

  39. Chris Avatar
    Chris

    Adding my thanks for a great registry hack!

    Back in the day I had all sorts of file extensions associated with Vim. Anything .txt, .log, and so on was associated with Vim. In the wonderful (sic) new world of Windows 7, I notice that I can’t just highlight a file and choose “Open With” and then browse to gvim.exe. I browse to it, but the file association has not changed. Have you encountered this? How’d you fix it?

    1. David Vielmetter Avatar

      Chris,

      In Windows 7 I don’t think the Open With context menu option has been removed, it just isn’t available for files that aren’t associated with any application. If I right click an xml file I see the open with option because xml files are associated with xmlspy but if I right click a sql file, for instance, I don’t see an open with option because I haven’t associated it with any applications. I guess there’s a registry edit to restore the open with functionality if you’ve accidentally removed it from windows…that regedit code is located below:

      Windows Registry Editor Version 5.00

      [HKEY_CLASSES_ROOT*shellexContextMenuHandlersOpen With]
      @=”{09799AFB-AD67-11d1-ABCD-00C04FC30936}”

      [HKEY_CLASSES_ROOT*shellexContextMenuHandlersOpen With EncryptionMenu]
      @=”{A470F8CF-A1E8-4f65-8335-227475AA5C46}

      Just copy it into a txt file and rename it to .reg, then merge it into your registry.

      David

  40. amol2670 Avatar
    amol2670

    Thanks for taking the time to publish this simple fix. Brilliant!

  41. FooBar Avatar
    FooBar

    Yet another “Thank you!”
    All those little things are becoming a real PITA when moving to win7/64..

  42. ahsiang Avatar

    I don’t need to do anything to get the context menu on my Win7.
    I downloaded the setup file from ftp://ftp.vim.org/pub/vim/pc/gvim73.exe and then run as administrator. The context menu is added just like WinXP time.
    GVIM is running as 32 bits since it is installed here:
    C:Program Files (x86)Vim
    Using Win7 Enterprise.

  43. binit Avatar
    binit

    Thanks a lot, this fix is short and very helpful.

  44. Dan Avatar
    Dan

    @ahsiang: Yes, it seems to be fixed as of Vim 7.3.

    Thanks for the stellar tip!! I was definitely using this regedit for my other Win7 box but as ahsiang mentioned it looks like this has been fixed as of the most recent release of Vim 7.3. Although, setting gVim as your default editor is still really handy. Thanks again.

  45. Piyush Nasa Avatar

    Thanks for sharing this information. I was stuck for such a long time and now this problem is solved.

  46. […] Found a link on the internet which describes what to do: https://davidvielmetter.com/?p=1094 […]

  47. Mark Purinton Avatar
    Mark Purinton

    Correction for Windows 7 x64 edition:

    @=””C:\Program Files (x86)\Vim\vim72\gvim.exe” “%1″”

    Thanks.

Skip to content