← Other topics

VSCode - Customize your keyboard shortcuts

Video Notes

Choose your operating system to customize the notes

Mac Windows Linux

To manage your keyboard shortcuts in VSCode, hold down cmd + shift + p to open the command palette and search for keyboard shortcuts then choose the option Preferences: Open Keyboard Shortcuts.

In the interface that appears you can search for any command within VSCode by name. Alternatively, if you click the keyboard icon in the search bar you can search by a key combination.

Editing shortcuts

Once you locate the command/shortcut you wish to edit, double click it and it will prompt you to enter the key combination (aka keybinding) you want to assign to that command.

If the key combination you enter is already being used by another command, it will let you know. When this happens, you will either have to choose a different key combination or change/remove the other command that is already using that key combination.

To remove a keybinding from a command, right click the command and choose Remove keybinding.

Context in which the shortcut will work

For each command, there’s a When clause that specifies the context of when that keybinding would apply. Here’s a list of all the available contexts.... To edit the When clause, right click the command and choose Change When Expression.

keybindings.json

All of your keybinding customizations are stored in a JSON file located at ~/Library/Application\ Support/Code/User/keybindings.json .

To quickly open this file hold down cmd + shift + p to open the command palette and search for keyboard shortcuts then choose the option Preferences: Open Keyboard Shortcuts (JSON).

If you have not yet made any customizations, the JSON object within this file will be empty:

// Place your key bindings in this file to override the defaults
[
]

Once you make customizations, they’ll be added to this file following the format shown in this example:

[
    {
        "key": "cmd+k",
        "command": "md-shortcut.toggleLink",
        "when": "editorTextFocus && markdownShortcuts:enabled"
    }
]

Each command should include a value for key, command, and optionally when. To find out the specific name for a command you can refer to the keybindings interface described above.

To disable a default command, prefix the command with a negative sign (-). Example:

{
    "key": "cmd+=", 
    "command": "-workbench.action.zoomIn" // Removes the default shortcut of zooming in interface with cmd +
},

If this info helped you out you can say thanks and support future content by clicking my Amazon affiliate link: https://amzn.to/3UtgnYk. If you make a purchase on Amazon within 24 hours of clicking the link I may receive a micro-commission and it costs you nothing extra. Any income from these sales goes directly to supporting me in making new videos and guides. Thank you for your support!

← Other topics