57

I would prefer to have Emacs keybindings in MSVS. In MSVS 2008, this was natively supported, and in MSVS2010 there was an extension to achieve this

http://blogs.msdn.com/b/visualstudio/archive/2010/09/01/emacs-emulation-extension-now-available.aspx

Can i install this extension in MSVS 2012? (I have thus far been unsuccessful...) Is there another way to achieve Emacs keybindings?

jaket
  • 9,140
  • 2
  • 25
  • 44
Woodrow Douglass
  • 2,605
  • 3
  • 25
  • 41

7 Answers7

76

I figured out how to get the emacs emulation extension for VS 2010 to install and run on VS 2012. This is a bit from memory, but here is what I did.

  1. Download the Emacs emulation extension.

  2. Rename it from EmacsEmulations.vsix to EmacsEmulations.zip and unzip into a folder.

  3. Edit the <VisualStudio Version="10.0"> value on the extensions.vsixmanifest file (XML):

    <SupportedProducts>
        <VisualStudio Version="11.0">
        <Edition>Pro</Edition>
        </VisualStudio>
    </SupportedProducts>
    

Note: Visual Studio 2013 works by setting Version="12.0". And VS Express can be used by setting <Edition>Express_All</Edition>

  1. Zip the content inside the folder back up and rename it back to EmacsEmulations.vsix.

  2. Run the vsix file as administrator. This is required so the extension can write Emacs.vsk into the program files folder. I wasn't sure the best way to do this so I ran a command prompt as admin and then executed start emacsemulations.vsix from the prompt.

  3. Start VS 2012 as Administrator (one time only). At this point, the extension should show up as installed in the extension manager and the keybinding should be listed in Tools/Options/Keyboard. Select the emacs keybindings.

  4. At this point it should be working. It wasn't working for me though, but I neglected run step 5 as admin so had to manually copy emacs.vsk into the right spot. When it still wasn't working I brought up the VS command window (Windows/Other Windows/Command Window) and typed Edit.EmacsBreakLine and the prompt and voila.

I don't have any more information than that so YMMV. Good luck!

jaket
  • 9,140
  • 2
  • 25
  • 44
  • Hmm...it installs, and Edit.EmacsBreakline shows up in the command list (amoung a bunch of other emacs commands) but still no keybindings :( – Woodrow Douglass Jan 02 '13 at 15:13
  • 1
    Does emacs show up in Tools/Options/Keyboard? I was in the same spot for awhile and had given up. Now that I think about it I might of run VS as admin. I also created a new text file, made a few lines of text and then started fiddling around with the command window. Good luck. – jaket Jan 03 '13 at 06:54
  • 13
    Also double check that Emacs.vsk is listed in `c:\program files (x86)\microsoft visual studio 11.0\common7\ide`. This is the file with the key binding assignments. – jaket Jan 03 '13 at 08:00
  • 16
    After following the above instructions, I still ended up copying `Emacs.vsk` from the unzipped files to `c:\program files (x86)\microsoft visual studio 11.0\common7\ide`. Then it worked. Awesome! Big thanks @jaket!! – Ray Feb 06 '13 at 06:03
  • 6
    I'm getting the following error when trying to run the vsix package: _This VSIX package is invalid because it does not contain the file extension.vsixmanifest at the root._ – dkleehammer Mar 29 '13 at 15:50
  • @Pantera61 I really wish someone would address. Im on my surface pro right now and its painful to develop anything. – Joey Arnold Andres Jul 04 '13 at 07:27
  • 8
    The manifest at root issue occured for me when I zipped up the folder. The windows tools created a zip->emacsemulation->all-the-files when it should be zip->all-the-files. Just select all the extracted files in the directory and zip those instead of the containing directory. – Baggers Jul 15 '13 at 22:31
  • 10
    Just a notice: for visual studio 2013 you should use `` – Resure Nov 24 '13 at 12:32
  • 3
    I am not able to get it to work for 2013, unless i run visual studio as administrator (my user doesn't have admin rights). I followed all the instructions, including copying the vsk file (to the 12.0 folder for my version of VS). I am able to see the emacs commands in the options, but they don't work. – Jeff Dec 18 '14 at 18:25
  • 2
    For visual studio 2013, I need to copy the Emacs.vsk to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE to make it appear in the options. – Tony Mar 12 '15 at 13:50
  • Should add `Emacs.vsk` to `c:\program files (x86)\microsoft visual studio 11.0\common7\ide` instead of `c:\program files\microsoft visual studio 11.0\common7\ide` !!! – Xing Shi Jun 15 '15 at 16:12
  • 2
    Visual Studio 2015 uses the version number "14.0"--Microsoft skipped over "13.0". – RealityMonster Feb 10 '16 at 15:52
  • Emacs emulation extension works pretty well, but "C-x o" didn't work for me as expected (in VS2015 it just does nothing). I'm using [VSStreamliner](https://visualstudiogallery.msdn.microsoft.com/6e2772e9-18e4-4409-8de4-8afec9e0603a) (with version hacked jas described in this post). I set keybindings "M-o" and "M-p" to "NextDocumentDown" and "NextDocumentUp" respectively. – dinosaur Aug 12 '16 at 18:23
  • EmacsEmulations for VS2015 is available [here](https://github.com/lrperlmu/EmacsEmulations2015/tree/master) if you want to skip the part where you edit the version manually. – dinosaur Aug 12 '16 at 19:15
  • It sort of works .. when I fire up VS, and I'm in the edit window, my keyboard is partially dead (I can add characters, but etc doesn't work. Only after I run the program, or create a separate text file, does it bring back the keyboard to life and fire up the Emacs bindings. Anyone have an idea why? It's workable this way - but cumbersome :-( Having these bindings makes the environment so much more usable. I wonder why MS wouldn't provide these a part of the standard install. – Levon Dec 04 '16 at 16:55
7

FYI: The emacs emulation extension is now open source.

ganaware
  • 163
  • 1
  • 4
4

If you want to make it work with the Express editions of VS2013, be sure to also change the Edition line to <Edition>Express_All</Edition>. See also the description of the Edition element.

skwillt
  • 41
  • 1
3

Jaket's method worked for me initially but stopped working after a few days. After searching for a solution in desperation, I then found XKeymacs [1] through a blog entry [2]. XKeymacs adds keymacs style keybindings to the entire windows environment, and works in Visual Studio as well. It might take some getting used to (e.g. Ctr-T doesn't work in IE anymore), but I am very happy being able to use emacs keybindings everywhere :)

  1. http://www.cam.hi-ho.ne.jp/oishi/indexen.html
  2. http://lexicalclosures.blogspot.com/2010/10/emacs-resharper-visual-studio-xkeymacs.html
Rahul Jha
  • 589
  • 3
  • 6
3

I don't believe all of the steps in the accepted answer are correct. Instead:

  1. Follow 1-4 as above to produce a suitable EmacsEmulations.vsix file.
  2. Install the extension as the user who needs the bindings and not as administrator.
  3. Manually copy the Emacs.vsk file from the unzipped content of the extension to the Common7\IDE folder in the Visual Studio program directory (for which you will need elevated permissions).

Running the extension as administrator will not achieve the desired file copy, nor will it allow other users to successfully use the new key bindings.

2

The trick that worked for me was to copy the Emacs.vsk file to the:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>

directory. Somehow when I first installed it, it had gotten copied to the

C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE>

directory

emlap
  • 21
  • 1
  • 3
0

To install the EmacsEmulations.vsix file for Microsoft Visual Studio Community 2015 (which reports its version as 14.0), there is an installer tool, VSIXInstaller.exe, in the folder:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>

After modifying the vsix file as per above (inserting version "14.0" and edition "Community" in my case), the following worked for me from an admin command line (fill in your own full paths):

VSIXInstaller.exe /a EmacsEmulations.vsix

Note that after selecting Emacs in the keyboard mapping drop down in Tools/Options/Environment, the change didn't seem to take right away. I restarted Visual Studio and it didn't take yet either.

I then searched for installed key bindings with "emacs" in the name and they were there. Seemingly after that they were then active in the editor, so I'm not 100% sure what it was that triggered the activation.

limey
  • 21
  • 1