Search code examples
visual-studio-codekeyboard-shortcutskey-bindings

VSCode Keybindings: Commands vs. Command Ids?


From my understanding, when inside of the keyboard shortcuts editor, the bold commands represent commands that are available in the command palette, while the light commands represent command ids. Is that accurate? And if so...

The command Insert Snippet is available from the command palette. This opens up the snippets menu. But if you search for this command from the keyboard shortcuts editor, it brings up a command id, which is not the same command. The Insert Snippet command has the same functionality as the editor.action.showSnippets command id. But when you search for this command id, it does not show the Insert Snippet command in bold above it.

This is the only command that I've come across so far that doesn't seem to align with what I thought the bold/light text meant. What am I missing?


Solution

  • It turns out that my understanding of bold and light commands was accurate.

    There are two explanations for what is going on with showSnippets and insertSnippet:

    • editor.action.showSnippets is an old command that still exists for compatibility.
    • The new command, editor.action.insertSnippet is not showing because it accepts arguments. And commands that accept arguments, but do not have any rules in keybindings.json where that command is declared with arguments, will not show in the keyboard shortcuts UI editor.

    Additional information found here and here.

    And for those reading this and still trying to figure out which command to use to show the snippet menu, the answer is editor.action.insertSnippet. As Alex noted, executing editor.action.insertSnippet without args will show the snippet menu (as opposed to directly inserting a specific snippet).