Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs key bindings in Visual Studio 2017

I'm trying to get Emacs style key bindings in VS 2017.
From the Q&As related to previous - VS - versions, I tried:

  • The VS settings (Tools->Options->Environment->Keyboard), but there is no Emacs option: apparently it was removed starting with VS 2010;
  • XKeymacs (though it seems antique, who knows?), but it only supports windows versions up to Vista and I'm running on windows 8;
  • VisEmacs, but it supports VS up to version 2008;
  • Downloaded the VS 2010 extension, extracted from archive, modified version (see note below for how I retrieved it), re-archived and ran it with the VSIXInstaller as explained in this answer.

    However, after I selected the Emacs option in the VS Keyboard mappings, and after several restarts, not only do the Emacs key bindings fail to work, but also the previous kbd mappings were disabled, even the common ones like Ctrl+arrows. I checked and the commands are there, they just don't work.

So here is where I got stuck.


N.B. In order to find the VS version:

C:\Program Files (x86)\Microsoft Visual Studio\Installer>vswhere.exe
Visual Studio Locator version 1.0.62 [query version 1.10.80.60812] Copyright (C) Microsoft Corporation. All rights reserved. installationName: VisualStudio/15.2.0+26430.16 installationPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community installationVersion: 15.0.26430.16

Tried with 15.2 and 15. (and 17 and 16 and 15.3, prior to that :) )


P.S. It seems like this question was asked for every VS version... This could be a hint for the VS team :).

like image 468
Ioanna Avatar asked Aug 02 '17 09:08

Ioanna


2 Answers

Tools -> Extensions and Updates -> (search Online) Emacs Emulation

like image 77
Ioanna Avatar answered Nov 05 '22 05:11

Ioanna


I've had to do this setup myself a number of times and thought I would try my hand at the 2017 variety so here it goes!

I followed the general instructions listed in other solutions here and here.

The extension.vsixmanifest has the following entries (only relevant section shown):

<SupportedProducts>
  <VisualStudio Version="15.0">
    <Edition>Pro</Edition>
  </VisualStudio>
  <VisualStudio Version="14.0">
    <Edition>Pro</Edition>
  </VisualStudio>
</SupportedProducts>

Version 15 will work with VS Community 2017. Edition should be Pro as there's no difference like there was in previous Express varieties.

Note that when you build the zip file, you need to do it such that the vsixmanifest, the dll, the pkgdef, etc. are all contained in the root of the zip. This means you shouldn't zip the EmacsEmulation folder, rather zip the contents from inside the folder.

I then opened up an administrator command prompt to install the file. Visual Studio 2017 was closed when I did this. I have my installation in the default folders.

"c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\ide\VSIXInstaller.exe" /a EmacsEmulation.vsix

Note I saw a bunch of warnings about this extension messing up VS 2017. Against all warnings I kept opting to install the extension.

Warning: The warnings about the extension being potentially incompatible with VS 2017 weren't far off. I was happy to see the key map was available when I opened Tools -> Options ... Environment / Keyboard but when I went to my code I couldn't get it to go to the beginning or end of line. I had to remove the keyboard shortcut for Editor Select All and restart VS before it worked properly. There may be other caveats to using this extension so YMMV.

Side note: I took my version that worked with 2015 and just added the version 15 to the XML. It seems to be "fine".

like image 34
Average Joe Avatar answered Nov 05 '22 05:11

Average Joe