Visual Studio + Emacs


Before joining MS, my editor of choice has always been Emacs, but now the default IDE for most of my work here has always been Visual Studio.  I have installed NTEmacs and tried to use it to do some dev work, but coding without intellisense (aka tab complete) has been a real challenge.  Why wasn't this a problem before at Amzn?  It's because I don't have choice, and most of the work doesn't have that deep, nested libraries to use.  So I was able to do just fine with copy/paste method names and variables and get away with things.

However, luck was finally on my side.  A few months ago, I stumbled upon "keyboard mapping scheme" on Vistual Studio 2005 (from the menu bar, it's under Tools > Options > Keyboard).  And guess what?  Emacs is there! 

VisualStudioEmacs

This means that from now on, I can edit source files using emacs keymaps AND I have intellisense built-in.  Life is good.  However, like most things in life, it came with a slight caveat (in this case, that caveat is a bug).  There is a problem with the kill ring buffer.  I was not able to copy/paste text across different source files (even when they are in the same project).  I filed a bug on this, and the good news is the fix should be released soon with one of their QFEs or Service Packs.

But again, many thanks to the Visual Studio team!

On a side note to that, I also noticed that VI is not listed in one of the schemes, and I think it's a sign that Emacs is better.  😀

Comments (14)

  1. howardprice says:

    Pasting across multiple files can be problematic.  I find that if the first paste (C-y) does not paste the desired text from the kill ring, then pressing A-y (Alt+y) once or more time will most of the time retrieve the correct result within attempts.

    When this does not work, try re-copying (A-w) or cutting (C-w) the source text and trying again.

    This really put a downer on my initial elation when I spotted the emacs mode in 2005!

  2. Dave says:

    I have been trying this but when I change to Emacs mode the "Home" and "End" keys (by themselves) take me to the start/end of the buffer instead of just to the end of the line.

    How can I fix this?  It is driving me nuts!!

    Thanks!

  3. ch4n says:

    Here is one way to assign "Home" and "End" to the start and end of the line.

    1) From menu bar, select "Tools", then "Options..."

    2) Click on "Keyboard" (which is under "Environment" section)

    3) Apply Emacs mapping scheme (duh)

    4) In the textbox under "Show commands containing...", type in "EmacsLineStart".  The list should show up "Edit.EmacsLineStart".  This is where we can set the keyboard setting for this command.

    5) Under "Use new shortcut in:" drop down box, select "Text Editor".

    6) Mouse click inside the "Press shortcut keys" text box, and hit the "Home" key.  The "Assign" button should now be enabled.

    7) Click Assign button.

    8) Voila!  Now, clicking on the home key should bring you to the beginning of the line.  Ctrl + A should still work.  Ctrl + Home should still bring you to the beginning of the buffer.

    For assigning the "End" key, just repeat the same steps, but you just want to assign the new shortcut setting to "Edit.EmacsLineEnd" command.

    Hope this helps!

  4. Woogon says:

    In the Visual C# 2005 Express Edition, how come I do not see nothing but the (Default) in the drop-down list box in the "Tools >> Options >> Keyboard"?

    How do I make Emacs choice available in the drop-down list box as a choice?

    Thanks.

    Woogon

  5. Christopher says:

    Apparently, the Emacs bindings are not available in the Express Editions.

  6. dikatour says:

    I happen to learn emacs thease days  And normally am a Windows programmer right now.Just a moment ago, I decided try to mix emacs & vs together, so i googled.Finally it came out that vs2005 has emacs keybord layout scheme...What a surprise!

  7. Chris says:

    The bindings for Emacs IS AVAILABLE in Visual C++ 2008 Express Edition.  I'm using it right now!

  8. Mike says:

    Is it possible to still have the auto indentation while using the emacs bindings? I am using VS2005 and its driving me a bit crazy to keep going back to format the code.

  9. Mike says:

    Just in case anyone is having the same problem as me, binding edit.breakline to enter seems to do some good.

  10. Lee says:

    Doesn't work at all:

    CTRL-X + P    (navigate to previous source page)

    CTRL-X + N   (navigate to next source page)

    ESC + V  (navigate to previous window page)

    CTRL-W  (cut everything between cursor and set mark)

    CTRL-X + F (set-fill-column)

    ESC + X

    ...

    Undo buffer is not "recursive"; undoing something after an undo does not bring everything back; after an undo command, everything it undid is permanently lost.

    You might as well get a real emacs and plug it in. Got any good suggestions for seamless plug-in?

  11. Ondrej Medek says:

    This bug with copy&paste is still not fixed. You can try

    http://www.cam.hi-ho.ne.jp/oishi/

  12. With a brand-new install of Visual Studio 2008, after I've selected the Emacs mapping scheme, I find that CTRL-A takes me to start-of-buffer and CTRL-E takes me to end-of-buffer, not to start and end of line as it should.  The keyboard mapping seems to show those keys bound to Edit.EmacsLineStart and Edit.EmacsLineEnd in the Text Editor, so i can't figure out what's wrong.  But those are two of the commands that I type most reflexively, so if I can't get this working, this isn't going to be usable.

  13. Yngwie malmsteen says:

    This thing ruuuuuuuules!

    Now I can give microsoft a try

    I love Emacs, Thanks GNU!

  14. Avi Cohen Stuart says:

    Thank you for showing it. I'm a long time emacs user and I 'hate' to use a different IDE.

Skip to main content