Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Visual Studio Code have a key binding resolver?

Tags:

The Atom editor has a command that is bound to 'ctrl-.' that is called the keybinding resolver:

enter image description here

Once you activate key-resolver mode, any key you subsequently press will tell you what command(s) are bound to it, in all possible contexts, and show you which command/context "wins out". You then toggle the mode off by pressing ctrl-g.

This is useful for when you want to know if a key binding is free, or if a key key binding isn't doing what you expect.

Here's an example output for when I press ctrl-n in an editor context , where I can see that the emacs keybinding 'next-line' is taking precedence:

enter image description here

Emacs also has a similar feature with it's ctrl-h k (help keys) command.

Yes, I can usually glean the information I need by browsing the Default Keyboard Shortcuts and keybindings.json, but this can be hard to do if a key is bound in a lot of different contexts.

Is there a feature similar to this in VSCode?

like image 815
vt5491 Avatar asked Aug 12 '16 06:08

vt5491


People also ask

How do you change key bindings VS Code?

All keyboard shortcuts in VS Code can be customized via the keybindings. json file. To configure keyboard shortcuts through the JSON file, open Keyboard Shortcuts editor and select the Open Keyboard Shortcuts (JSON) button on the right of the editor title bar. This will open your keybindings.

What is the code to reset key bindings in Visual Studio?

Click File > Preferences > Keyboard Shortcuts. There is a triple-dot (...) at the top-right hand corner. Click on that and select "Show User Keybindings" Delete your listed keybindings.

How do you resolve Save conflict VS Code?

VS Code blocks saving the file to prevent overwriting changes that have been made outside of the editor. Use the actions in the editor toolbar to resolve the save conflict. You can either Accept your changes and thereby overwriting any changes on disk, or Revert to the version on disk.

How do I find Visual Studio code keywords?

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.


2 Answers

Unfortunately not and as far as I know it currently can't be done using extensions API. The feature request for this feature can be found here.

Visual Studio Code evaluates keybindings as follows:

  • the rules are evaluated from bottom to top.
  • the first rule that matches, both the key and in terms of when, is accepted.
  • no more rules are processed.
  • if a rule is found and has a command set, the command is executed.

The additional User/keybindings.json rules are appended at runtime to the bottom of the default rules, thus allowing them to overwrite the default rules.

For now you can check what is bound to a specific key using Quick Outline Preferences: Open Keyboard Shortcuts. To open this view, press ++P on Mac or Ctrl+Shift+P on Windows & Linux, and look for this option.

enter image description here

Looking at the development pace this might be doable as extension or included in vscode in upcoming months.

like image 184
Jakub Synowiec Avatar answered Oct 03 '22 03:10

Jakub Synowiec


Not sure when the feature was added, but now in the Keyboard Shortcuts menu reached via Ctrl+K, Ctrl+S, you can click the small keyboard icon in the right of the search field, or alternatively press Alt+K, to Record Keys

Record Keys button

vscode will capture the key command you enter and display results for it, rather than having to enter text description of the key command in correct syntax, which is almost like the keybinding resolver in atom.

like image 7
Koleok Avatar answered Oct 03 '22 03:10

Koleok