Visual Studio Code Keyboard Shortcut Cheat Sheet

Visual Studio Code lets you perform most tasks directly from the keyboard. This page lists out the default bindings (keyboard shortcuts) and describes how you can update them.

Keyboard Shortcuts Editor

Visual Studio Code provides a rich and easy keyboard shortcuts editing experience using Keyboard Shortcuts editor. It lists all available commands with and without keybindings and you can easily change / remove / reset their keybindings using the available actions. It also has a search box on the top that helps you in finding commands or keybindings. You can open this editor by going to the menu under File > Preferences > Keyboard Shortcuts. (Code > Preferences > Keyboard Shortcuts on macOS).

Most importantly, you can see keybindings according to your keyboard layout. For example, key binding Cmd+\ in US keyboard layout will be shown as Ctrl+Shift+Alt+Cmd+7 when layout is changed to German. The dialog to enter key binding will assign the correct and desired key binding as per your keyboard layout.

Keyboard Shortcut Action
Alt + Click add additional cursor
Alt + F12 peek definition
Alt + F4 close window
Alt + Left navigate between files
Alt + Right navigate between files
Ctrl + / split active editor
Ctrl + ` cycle open editors
Ctrl + = zoom in
Ctrl + – zoom out
Ctrl + 1 focus left editor
Ctrl + 2 focus right editor
Ctrl + Alt + ] jump to matching bracket
Ctrl + Alt + click open definition to side
Ctrl + Alt + Down add cursor below
Ctrl + Alt + Up add cursor up
Ctrl + B toggle sidebar
Ctrl + Click open file to side
Ctrl + Click go to definition
Ctrl + E go to  file
Ctrl + Enter open file to side
Ctrl + F12 go to definition
Ctrl + F2 add cursor to each occurrence of current word
Ctrl + G go to line
Ctrl + Shift + D debug
Ctrl + Shift + E explore
Ctrl + Shift + F search all files
Ctrl + Shift + I shows windows
Ctrl + Shift + J advanced search all files
Ctrl + Shift + L add cursor to each occurrence of current selected text
Ctrl + Shift + M list all current errors
Ctrl + shift + O navigate to symbol
Ctrl + Shift + P open control pallet
Ctrl + Shift + U output
Ctrl + Shift + W close window
Ctrl + Space trigger IntelliSense
Ctrl + T jump to symbol across files
Ctrl + Tab cycle files
Ctrl + W close editor
F2 rename symbol
F11 full screen
Shift + F12 reference search

Keyboard rules

The keyboard shortcuts dispatching is done by analyzing a list of rules that are expressed in JSON. Here are some examples:

// Keybindings that are active when the focus is in the editor
{ "key": "home",            "command": "cursorHome",                  "when": "editorTextFocus" },
{ "key": "shift+home",      "command": "cursorHomeSelect",            "when": "editorTextFocus" },

// Keybindings that are complementary
{ "key": "f5",              "command": "workbench.action.debug.continue", "when": "inDebugMode" },
{ "key": "f5",              "command": "workbench.action.debug.start",    "when": "!inDebugMode" },

// Global keybindings
{ "key": "ctrl+f",          "command": "actions.find" },
{ "key": "alt+left",        "command": "workbench.action.navigateBack" },
{ "key": "alt+right",       "command": "workbench.action.navigateForward" },

// Global keybindings using chords (two separate keypress actions)
{ "key": "ctrl+k enter",    "command": "workbench.action.keepEditor" },
{ "key": "ctrl+k ctrl+w",   "command": "workbench.action.closeAllEditors" },

Each rule consists of:

  • key that describes the pressed keys.
  • command containing the identifier of the command to execute.
  • an optional when clause containing a boolean expression that will be evaluated depending on the current context.

Chords (two separate keypress actions) are described by separating the two keypresses with a space. For example, Ctrl+K Ctrl+C.

When a key is pressed:

  • 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 keybindings.json rules are appended at runtime to the bottom of the default rules, thus allowing them to overwrite the default rules. The keybindings.json file is watched by VS Code so editing it while VS Code is running will update the rules at runtime.

0 0 votes
Article Rating

Do you want to hire us for your Project Work? Then Contact US.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x