Visual Studio Emacs



This Visual Studio Code extension provides emacs-like keybindings and operations. This is inspired by the great vscode extension by hiro-sun and its forks such as vscode-emacs-friendly by Sebastian Zaha, vscode-emacs-improved by rkwan94 and vscode-emacs-neon by NotKyon. Years ago, Visual Studio had Emacs keybindings as an built-in option, later versions as an add-on. I don't know which version is current and if the addon still works. I also used the Resharper addon from Jetbrains. Maybe this tool also had some Emacs keybindings. When using emacs mode in Visual Studio 2008 the tab key no longer inserts tabs. It simply formats the current line. It is possible to remap tab to Edit.IncreaseIndent but this has many undesirable side effects. Has anyone else experienced this? This project provides Emacs key bindings for Visual Studio users, through a Visual Studio Extension. This capability was available in VS2008, but was removed in VS2010 and VS2012. Emulation was released as a Visual Studio Extension called the 'Emacs Emulation' extension.Since the extension has not been supported by the Visual Studio Team since 2010, I was able to make the. Installing Emacs Emulation requires 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.

WindowsEmacsVisualStudio

macOS provide Emacs keybinding as a natively. At least, I need it on Visual Studio of Windows.

Visual Studio Code Emacs Keybindings

Introduction

If you must get Ctrl+A to be a keybinding that moves the cursor to the beginning of a line in Visual Studio, install Emacs emulation 2.This post will make your wish come true.

How to setup

Open Extentions > Manage Extensions.

Type emacs in Search bar. Then, click Download button. If it finished, Quit Visual Studio.

Windows show VSIX Installer. Take care of it.

Next, launch Visual Studio and Open someone project. So, appear Emacs emulation's dialog. Click OK on the one.

Open Tools > Options..., then select Emacs in Environment > Keyboard.

Select Emacs, click OK.

Visual Studio Code Vs Emacs

Visual Studio Emacs

The installation maybe completed with the above. So please try Ctrl + A on text editor in Visual Studio.

Visual Studio Emacs Emulation 2

References

Visual Studio 2017 Emacs Keybindings

This plugin provides emacs keybindings and workflow for Visual Studio Code and is a fork of the great vscode extension by hiro-sun.

It merges some of the pull requests in the original and other external helpers that make the extension a little less an exact copy of emacs behavior, and a little more friendly in interacting with the system clipboard and normal vscode interactions.

The following are some of the changes and enhancements from the original:

  • The clipboard handling is simplified by the removal of the emacs-only kill ring (which was also an unfinished implementation in the original). Copy, Cut, Yank and C-K work with the system clipboard now.
  • C+x k to close tab, C+x C-k all tabs
  • C+l centers screen on the cursor line
  • C+x C+f bound to quick open file
  • yank overwrites selection

Move commands

CommandDesc
C-fMove forward
C-bMove backward
C-nMove to the next line
C-pMove to the previous line
C-aMove to the beginning of line
C-eMove to the end of line
M-fMove forward by one word unit
M-bMove backward by one word unit
M->Move to the end of buffer
M-<Move to the beginning of buffer
C-vScroll down by one screen unit
M-vScroll up by one screen unit
M-g gJump to line (command palette)
M-g nJump to next error
M-g pJump to previous error
C-lCenter screen on current line

Search Commands

CommandDesc
C-sSearch forward
C-rSearch backward
A-%Replace
C-EnterReplace One Match (In replace dialog)
C-M-nAdd selection to next find match

Edit commands

CommandDesc
C-dDelete right (DEL)
C-hDelete left (BACKSPACE)
M-dDelete word
M-BkspDelete word left
C-kKill to line end
C-S-BkspKill entire line
C-oopen-line
C-wKill region
M-wCopy region to kill ring
C-yYank
C-jEnter
C-mEnter
C-x C-oDelete blank lines around
C-x hSelect All
C-x u (C-/, C-_)Undo
C-;Toggle line comment in and out
M-;Toggle region comment in and out
C-x C-lConvert to lower case
C-x C-uConvert to upper case

Other Commands

CommandDesc
C-gCancel
C-spaceSet mark
C-quoteIntelliSense Suggestion
M-xOpen command palette
C-M-SPCToggle SideBar visibility
C-x zToggle Zen Mode
C-x rOpen Recent

File Commands

CommandDesc
C-x C-sSave
C-x C-wSave as
C-x C-nOpen new window

Tab / Buffer Manipulation Commands

CommandDesc
C-x bSwitch to another open buffer
C-x C-fQuickOpen a file
C-x kClose current tab (buffer)
C-x C-kClose all tabs
C-x 0Close editors in the current group.
C-x 1Close editors in other (split) group.
C-x 2Split editor horizontal
C-x 3Split editor vertical
C-x 4Toggle split layout (vertical to horizontal)
C-x oFocus other split editor

Conflicts with default key bindings

  • ctrl+d: editor.action.addSelectionToNextFindMatch => Use ctrl+alt+n instead;
  • ctrl+g: workbench.action.gotoLine => Use alt+g g instead;
  • ctrl+b: workbench.action.toggleSidebarVisibility => Use ctrl+alt+space instead;
  • ctrl+space: toggleSuggestionDetails, editor.action.triggerSuggest => Use ctrl+' instead;
  • ctrl+x: editor.action.clipboardCutAction => Use ctrl+w instead;
  • ctrl+v: editor.action.clipboardPasteAction => Use ctrl+y instead;
  • ctrl+k: editor.debug.action.showDebugHover, editor.action.trimTrailingWhitespace, editor.action.showHover, editor.action.removeCommentLine, editor.action.addCommentLine, editor.action.openDeclarationToTheSide;
  • ctrl+k z: workbench.action.toggleZenMode => Use ctrl+x z instead;
  • ctrl+y: redo;
  • ctrl+m: editor.action.toggleTabFocusMode;
  • ctrl+/: editor.action.commentLine => Use ctrl+; instead;
  • ctrl+p & ctrl+e: workbench.action.quickOpen => Use ctrl+x b instead;
  • ctrl+p: workbench.action.quickOpenNavigateNext => Use ctrl+n instead.
  • ctrl+o: workbench.action.files.openFile => Use ctrl+x ctrl+f instead.
  • ctrl+r: workbench.action.openRecent => Use ctrl+x r instead.

The logo is from the great Pacifica Icon Set.