1001Ferramentas
⌨️ Dev

VS Code Keybinding Generator

Generate entries for VS Code keybindings.json with key, command and when-context. Custom shortcut in seconds.

A VS Code keybinding with the right when clause

The VS Code keybindings file is an array of objects with three fields: the key combination, the command and, optionally, the condition under which the binding applies. The first two are obvious; the third separates a configuration that works from one that gets in the way, because without it the binding applies in every context, including inside the integrated terminal and the search box.

Fill in the fields and the page assembles the JSON ready to paste. The combination follows the editor's notation, keys joined by plus signs and chords separated by a space — two shortcuts in sequence, Emacs style. The command is the internal identifier, which you find in the command palette by turning on identifier display.

On the condition, the most useful expressions are worth knowing: the one restricting to a focused text editor, the one requiring an active selection, the one limiting to a specific language and the one testing whether the terminal has focus. They combine with the usual logical operators. To remove a default binding rather than override it, declare the same command with a minus sign in front.

Frequently asked questions

Where does the file live?
It opens from the command palette, through the option to open keyboard shortcuts as JSON. On disk it sits in the user configuration folder, which varies by system. Editing it that way is safer than hunting for the path, because the editor validates the JSON as you type.
My binding does nothing. Why?
The two common causes are conflict and context. Conflicts show up in the shortcuts view, which flags when two entries compete for the same combination — the last one in the file wins. Context is the when clause: without it the binding applies everywhere, and with the wrong one it applies nowhere.
How do I find a command identifier?
In the shortcuts view, the context menu offers copying the command identifier. You can also enable identifier display in the command palette, which shows the internal name beside each label — handy when the command has no binding yet at all.

Related Tools