Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find command by pressing keybinding in VSCode

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.)

like image 837
Razzi Abuissa Avatar asked Sep 12 '18 20:09

Razzi Abuissa


People also ask

How do I find the command in VS Code?

VS Code allows you to quickly search over all files in the currently opened folder. Press Ctrl+Shift+F and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location.

What is Ctrl Shift P in VS Code?

You can define a keyboard shortcut for any task. From the Command Palette (Ctrl+Shift+P), select Preferences: Open Keyboard Shortcuts File, bind the desired shortcut to the workbench.

What is Ctrl K in VS Code?

To launch the Define Keybinding widget, press Ctrl+K Ctrl+K. The widget listens for key presses and renders the serialized JSON representation in the text box and below it, the keys that VS Code has detected under your current keyboard layout.

What is Ctrl Shift L in VS Code?

Press Ctrl + Shift + L . This will select all words that match your current selection. It also adds a cursor to each text span matching your current selection. Simply start typing your replacement text and vscode will start replacing all instances of text matching your selection in-editor as you type.


1 Answers

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.

like image 101
Ankit Avatar answered Sep 28 '22 01:09

Ankit