iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🆚

Using Emacs Keybindings in Visual Studio 2022

に公開

I haven't used Visual Studio in a while, and since I ran into several issues while setting up Emacs keybindings, I'm writing this as a memo.

For reference, when I used it in the past:

  • During the era when Emacs keybindings were natively supported in Visual Studio (up to 2008), I used those.
  • After they were no longer natively supported and became an extension, I used XKeymacs instead of the extension.

That was my setup.

This time, these are the steps for Visual Studio 2022.

Modifying and Installing the Emacs Keybinding Extension

An extension called "Emacs Emulation" is available on the Marketplace, and it seems many people install this.

I installed and tried it, but there were several things that didn't work for me.

  1. Cannot delete after selecting a range using the Delete key.
  2. When completing with IntelliCode, it enters the mark state.
  3. Confirming with the Tab key in IntelliCode or Copilot doesn't work (conflicts because it controls the Tab key).
    • I had to work around this by disabling the Tab key assignment in Emacs Emulation.

Initially, I tried various things to see if I could fix it through key assignment settings while using this extension.
However, it didn't work well, so I gave up and decided to fork Emacs Emulation, modify the code, and use it.
The built version is available below.

Other Key Assignment Changes

I have unintentionally become accustomed to using the Home/End keys to move to the beginning/end of a line. Since moving to the beginning/end of a file in Emacs Emulation became a hindrance instead, I decided to reassign the Home/End keys to move to the beginning/end of a line.

Also, I changed the shortcut for displaying completion suggestions to Ctrl+/. (I always use Ctrl+/ when using Emacs keybindings in other IDEs as well.)

Eventually, I ended up assigning the following.

Command Shortcut
Edit.LineStart Home (Text Editor)
Edit.LineStartExtend Shift+Home (Text Editor)
Edit.LineEnd End (Text Editor)
Edit.LineEndExtend Shift+End (Text Editor)
Edit.ListMembers Ctrl+/ (Text Editor)

Discussion