Emacs Emulation Extension Now Available!

Emacs Emulation Extension Now Available!

Rate This
  • Comments 53

We are pleased to announce the availability of Emacs Emulation as a free extension for Visual Studio 2010!  This extension provides basic support for Emacs keybindings and text editing commands, very similar to the built-in Emacs keyboard layout in VS 2008.  Once the extension is installed you should be able to use familiar keyboard shortcuts to execute Emacs commands within VS 2010.

Installation and Setup

Installing Emacs Emulation requires Visual Studio 2010 Pro, Premium, or Ultimate (the Express editions do not support extensions) and a one-time elevation to administrator permissions.  This elevation is necessary to install the keybindings file in the Visual Studio Program Folder.  The first time you launch Visual Studio after downloading and installing the extension, you should see a permissions dialog, shown below.  Click OK and follow the system prompt to elevate.  This is only required once; subsequent launches of Visual Studio will not prompt for elevation.

Elevated permissions dialog for Emacs emulation

After installing the extension and keybindings file, go to Tools->Options->Keyboard to select the Emacs keyboard mapping scheme, as shown below:

Choose "Emacs" as the keyboard mapping scheme

Using the Emacs Keyboard Layout

You can begin using Emacs shortcuts as soon as you’ve selected Emacs as your keyboard mapping scheme.  Some of the most common Emacs shortcuts supported by this extension are:

General Shortcut Keys


Command

Keys

Description

Edit.EmacsExtendedCommand

ALT + X

Places the cursor in the Find/Command box on the Standard toolbar.

Edit.EmacsFindReplace

SHIFT + ALT + 5

Displays the replace options in the Quick tab of the Find and Replace dialog box.

Edit.EmacsPasteRotate

ALT + Y

Pastes an item from the Clipboard Ring tab of the Toolbox to the file and automatically selects the pasted item. Press ALT + Y again to paste the next item to the Clipboard Ring.

Edit.EmacsQuit

CTRL + G

Stops the current command or code and deactivates the region.

Edit.EmacsUniversalArgument

CTRL + U

Prompts for an integer, returns negative if the first character entered is a hyphen. When a non-digit character is entered, the prefix for the command is set to the entered integer. If no integer is entered, the default value is 4. Repeatedly invoking the command multiplies the current value entered by the previous accumulated value.

Text Manipulation


Command

Keys

Description

Edit.EmacsBreakLine

ENTER

Inserts a new line.

Edit.EmacsBreakLineIndent

CTRL + J

Inserts a new line and indents it.

Edit.EmacsCharTranspose

CTRL + T

Transposes the characters on either side of the cursor. For example, Ed|n Sub would be changed to read End| Sub.

Edit.EmacsDeleteSelection

CTRL + DELETE

Deletes the current selection.

Edit.EmacsDeleteToEOL

CTRL + K

Deletes from the cursor to the end of the current line.

Edit.EmacsLineOpen

CTRL + O

Inserts a new line after the cursor. The cursor stays in the current line.

Edit.EmacsQuotedInsert

CTRL + Q

Reads another key and inserts the key into the buffer. Keys must be 8-bit ASCII characters. Use this command to insert control characters, meta characters, or graphics characters into the buffer.

Edit.EmacsWordCapitalize

ALT + C

Capitalizes the character to the right of the cursor or the first character of the next word if the cursor is between words.

Edit.EmacsWordDeleteToEnd

ALT + D

Deletes the characters to the right of the cursor to the end of the word.

Edit.EmacsWordDeleteToStart

ALT + BACKSPACE
—or—
ALT + DELETE

Deletes the characters from the left of the cursor to the start of the word.

Edit.EmacsWordLowercase

ALT + L

Changes the selected text to lowercase characters.

Edit.EmacsWordTranspose

ALT + T

Transposes the words on either side of the cursor. For example, |End Sub would be changed to read Sub End|.

Edit.EmacsWordUppercase

ALT + U

Changes the selected text to uppercase characters.

Text Navigation


Command

Keys

Description

Edit.EmacsCharLeft

CTRL + B

Moves the cursor one character to the left.

Edit.EmacsCharRight

CTRL + F

Moves the cursor one character to the right.

Edit.EmacsDocumentEnd

END
—or—
SHIFT + ALT + . (period)
—or—
SHIFT + END
—or—
CTRL + X, ]

Moves the cursor to the bottom of the current document.

Edit.EmacsDocumentStart

HOME
—or—
SHIFT + ALT + , (comma)
—or—
SHIFT + HOME
—or—
CTRL + X, [

Moves the cursor to the top of the current document.

Edit.EmacsGoToLine

ALT + G

Displays the Go To Line dialog box, which allows you to navigate to a specific line of code in the current document.

Edit.EmacsLineDown

CTRL + N

Moves the cursor down one line.

Edit.EmacsLineEnd

CTRL + E

Moves the cursor to the end of the current line. If you use word wrap, the cursor moves to the physical, not the displayed, end of the current line.

Edit.EmacsLineStart

CTRL + A

Moves the cursor to the beginning of the current line. If you use word wrap, the cursor moves to the physical, not the displayed, beginning of the current line.

Edit.EmacsLineUp

CTRL + P

Moves the cursor up one line.

Edit.EmacsPopMark

CTRL + X, CTRL + SPACEBAR
—or—
CTRL + X, CTRL + SHIFT + 2

Moves the cursor to the current mark and then removes the mark for the location stack.

Edit.EmacsScrollLineCenter

CTRL + L

Scrolls the document so that the current line is now in the center of the viewable area in the editor.

Edit.EmacsScrollLineTop

SHIFT + ALT + 1

Scrolls the document so that the current line appears at the top of the viewable area in the editor.

Edit.EmacsScrollPageDown

CTRL + V

Scrolls down within the document.

Edit.EmacsScrollPageUp

ALT + V

Scrolls up within the document.

Edit.EmacsSetMark

CTRL + SHIFT + 2
—or—
CTRL + SPACEBAR

Adds a mark to the location stack for the current cursor.

Edit.EmacsSwapPointAndMark

CTRL + X, CTRL + X

Moves the cursor to the current mark in the location stack and moves the current mark to the location where the cursor mark was when the command was invoked.

Edit.EmacsWordNext

CTRL + RIGHT ARROW
—or—
ALT + F
—or—
ALT + RIGHT ARROW

Moves the cursor to the first character in the next word.

Edit.EmacsWordPrevious

CTRL + LEFT ARROW
—or—
ALT + B
—or—
ALT + LEFT ARROW

Moves the cursor to the first character in the previous word.

File Management


Command

Keys

Description

Edit.EmacsFileSaveDirty

CTRL + X, S

Displays a list of modified files and allows you to select which files to save.

Window Management


Command

Keys

Description

Edit.EmacsCloseOtherWindow

CTRL + X, 1

When a window is split, this shortcut closes the pane that does not have focus.

Edit.EmacsOtherWindow

CTRL + X, O

Switches focus between panes when a window is split.

Edit.EmacsSplitVertical

CTRL + X, 2

Splits the current document in half vertically. The current line of code is centered in each window.

Using the Emacs Commands

Once you’ve installed the Emacs Emulations extension, all of the Emacs shortcuts it enables are fully customizable.  If you choose to use the Emacs keyboard schema, you’ll automatically get the shortcuts listed above.  If you don’t like a particular keybinding in the Emacs schema, you can always change it through Tools->Options->Keyboard.  You can switch keyboard layouts or customize shortcuts for specific commands (Emacs or otherwise) at any time.

Feedback

We’re always interested in your feedback on Visual Studio and extensions published by Microsoft.  In fact, this extension was created largely in response to your feedback that removing Emacs emulation from VS 2010 was causing significant pain on a daily basis; we hope we’ve addressed that pain with this extension.  If you have questions or comments about Emacs Emulation, feel free to post them in the blog comments here.  If you find a specific bug in the Emacs Emulation extension, please file a Connect bug report so we can investigate in more detail.

Enjoy!

Brittany Behrens
Program Manager, Visual Studio Editor

Leave a Comment
  • Please add 3 and 7 and type the answer here:
  • Post
  • Thank you -- this extension was literally the deciding factor between staying with VS2008 and upgrading to VS2010, which I have now done!

    One thing you might want to add to the documentation: the extension does not work until a solution is opened.  I installed the extension and launched VS2010 but it did not give me the priv. esc. dialog, and did not offer Emacs in the list of keyboard bindings.  I uninstalled and reinstalled several times, restarting VS2010 each time, with no luck.  Finally I tried opening a solution and I got the dialog box.  Emacs then appeared in the list of valid key bindings, but switching to Emacs mode had no effect.  I shut down and restarted VS2010 one last time and now everything works as expected.

    Thanks again!

  • Is it possible to copy-paste from another program into VS?

  • @uscjeremy:  The fact that the extension doesn't kick in until a solution is opened is intentional.  We would love to remove this restriction, but unfortunately that would cause performance to drop significantly.  I will add this to the known issues section on the VS Gallery page, though.

    @Elyseum:  It certainly should be; the fact that this doesn't currently work is a known bug.  We have a tentative fix and are working on publishing an updated version of the extension that allows copy-paste from other applications into VS.

    Thanks for posting!

    Brittany

  • Is there a Brief Emulation extension coming soon? That's the one thing keeping us at VS2008.

  • @Mark McGregor:  Unfortunately no.  We're not working on a Brief emulation extension and don't currently plan to create one.  Although usage numbers aren't the only factor we consider, the Emacs user base dwarfs the Brief user base even among the relatively small percentage of VS customers who use emulations.  I truly wish we could include everything that was available in previous versions, but unfortunately it's not always possible.

    - Brittany

  • I'm really looking forward to the Tab issue being fixed. It's very frustrating to be cruising along and then suddenly realize that some code somewhere has been erased by my habitual use of the Tab key.

  • One issue is indeed the tab issue.

    Another one equal annoying is the following: In emacs when you select a couple of characters and you start to type, the selection is deleted. This doesn't happen with the emacs emulation mode.

    The same happens with the del or the backspace: only one char is deleted and not the whole selection.

    But thanks in any case for the emacs support

  • I also wish there was a Brief emulation.  I go back and forth between SlickEdit (whose Brief emulation was always superior to VS2008) and the editor in VS2010.

  • Add VS functionality to Emacs and your training will be complete, young Jedi.

  • Hi there,

    Emacs emulation is absolutely awesome, thanks so much for adding it. It really makes VS so much more usable for me.

    The paste problem is a bit of an issue, though. I find myself copying and pasting code from the web quite often. Any word on when it might be fixed?

    In the meantime, has anyone found an efficient workaround?

    Cheers,

    - alex.

  • What does it mean that it is "fully customizable"? I can only see a dialog for changing the keybindings, but it does not allow me to define new functions. I see that C-u is universal-argument, but there is no digit-argument on C-1, C-2, etc.

    Also, When I hit C-s it does not do incremental search-- isearch-forward is essential for quickly finding things in a document (and isearch-forward-regexp is even more useful).

    And whenever I hit the meta key it makes the Start menu open. In fact, I don't see anything bound to a meta key in your list above, so does that mean that functionality does not exist? There are some pretty basic editing features that by default are bound to meta keys like M-h for mark-paragraph, M-( for insert-parentheses, and so on. Also, for some reason some things that should be bound to the meta key are instead bound to the Alt key which is very confusing since M-v should scroll the page down, not A-v.

    This is very frustrating.

  • I love the Emacs functionalities in VS2008 and just wish to be able to use the same in VS2010 as well. How come the extension for VS2010 is so hard to implement now? It is fully bugged as I can read here, but one major issue has stopped me totally from using it. The issue with TAB when trying to indent lines rapidly must be fixed soon. It's very annoying that it deletes the current line you want to indent and makes the whole extension useless. I really hope you get this fixed soon. Any updates on this?  

  • Unfortunately our dev team has already made the decision to move to VS2010 and I've just discovered that there's no Brief Emulation support.  This is a disaster!

  • We have an entire department stuck at VS2008 because of the lack of Brief in VS2010.

  • Peter/Others with issues with the tabbing - hopefully you read this. As a brute force hack around the tabbing issue I created a quick macro to do this properly:

       Sub FormatAndGoHome()

           DTE.ExecuteCommand("Edit.FormatSelection")

           DTE.ExecuteCommand("Edit.EmacsWordNext")

           DTE.ExecuteCommand("Edit.EmacsWordPrevious")

       End Sub

    It's a tiny bit slower, but at least it doesn't delete!

Page 2 of 4 (53 items) 1234