24

I'm looking for a way for VS Code to tell me the command name for a keybinding.

In Emacs, this functionality is available under describe-key (C-h k).

For example, in VS Code A maps to editor.action.selectAll. So ideally I'd press a keyboard shortcut, then A, then VS Code would tell me editor.action.selectAll.

As a partial solution, I can open my keybindings.json and search for A, but this doesn't work for extensions. (My particular use case is figuring out what the Vim o command is called so I can remap it.)

David J.
  • 31,569
  • 22
  • 122
  • 174
Razzi Abuissa
  • 3,337
  • 2
  • 28
  • 29
  • 6
    Thank you for mentioning "C-h k", that's how I found this question ;-) – SamB Apr 18 '19 at 00:39
  • I'm removing the "emacs" tag, since this is a question about Microsoft's VS Code editor. The OP mentions Emacs as a point of comparison only. – David J. Jan 27 '21 at 16:09

2 Answers2

12

You can find the command associated with a key binding by typing the keybinding into the Keyboard Shortcuts search box:

keyboard shortcuts

Unfortunately, per the source code, the vim extension doesn't use this mechanism to bind the o key.

Fortunately, it does let you rebind the keys in settings. First, open settings (F1 Preferences: Open Settings), then add (to bind i, for example):

"vim.normalModeKeyBindingsNonRecursive": [
    "before": ["i"],
    "after": ["o"]
],

If you have the new settings UI, you might need to search for vim.normalModeKeyBindingsNonRecursive first, and then click Edit in settings.json.

Ankit
  • 1,861
  • 18
  • 18
  • 4
    Also see https://stackoverflow.com/questions/46287561/how-do-i-find-out-which-command-name-is-bound-to-a-particular-key-sequence-in-vs/52709734#52709734 for an improvement to searching for bound keystrokes and commands. – Mark Oct 08 '18 at 20:37
8

As of the September 2018 release, VSCode can do this from the keyboard shortcuts window.

Screenshot of keyboard shortcuts pane with recording keys active

From the keyboard shortcuts window (cmd+k cmd+s), type cmd+option+k or click the keyboard icon on the right.

Kudos to this comment linking to this approach as an answer to another question.

Razzi Abuissa
  • 3,337
  • 2
  • 28
  • 29
  • This is a duplicate answer - see my comment above. – Mark Oct 31 '18 at 18:00
  • 1
    Sorry, I wanted to have this as an answer and didn't know the etiquette in this case. I can remove this answer though I do feel the updated screenshot provides value. Thanks for your comments. – Razzi Abuissa Oct 31 '18 at 18:24
  • I would do two things in your answer: explicitly reference the comment above and then upvote that actual answer on the commented link since you did find it helpful. Neither of these is required of course, I just think it is the nicest way to handle it. – Mark Oct 31 '18 at 19:51