VS Code Keybindings Cheat Sheet

Sidebar

Programming · VS Code Keybindings Cheat Sheet

How to change VS Code's keyboard shortcuts in keybindings.json, plus the default Windows/Linux shortcuts worth knowing. On macOS, Ctrl is usually Cmd. Sheet 7 in the VS Code series.

Finding & Changing Shortcuts

Ctrl+K Ctrl+SOpen the Keyboard Shortcuts editor (search by command name or by pressing the keys)
Open Keyboard Shortcuts (JSON)Button in that editor's title bar: opens your own keybindings.json
Preferences: Open Default Keyboard Shortcuts (JSON)Command Palette: read-only list of every default binding
Copy Command IDRight-click a row in the editor: gives the command ID to use in keybindings.json
Help > Keyboard Shortcuts ReferenceOpens the official printable PDF of the defaults
Developer: Toggle Keyboard Shortcuts TroubleshootingLogs each pressed shortcut and the command it ran, in the Output panel

keybindings.json Syntax

{ "key": "ctrl+f", "command": "actions.find", "when": "editorTextFocus" }One rule: the keys, the command ID, and an optional condition
"command": "-jumpToNextSnippetPlaceholder"A leading minus removes a default binding; use the same key and when as the original
"command": ""An empty command unbinds that key everywhere
"key": "ctrl+k ctrl+w"A space between key presses makes a two-step chord
argsExtra input for a command, e.g. { "text": "ls\u000D" } for workbench.action.terminal.sendSequence
// commentskeybindings.json accepts comments, like settings.json

Key Names & when Clauses

Modifiersctrl, shift, alt, and win on Windows (cmd on macOS, meta on Linux)
Named keysf1–f19, left, pageup, tab, enter, escape, space, backspace, delete, numpad0–numpad9
editorTextFocusTrue when the text editor has focus
terminalFocusTrue when the integrated terminal has focus
!editorReadonlyTrue when the editor is not read-only
editorLangId == pythonTrue only in one language
resourceExtname == .mdTrue for files with that extension
&&   ||   !   =~AND, OR, NOT, and regular-expression match, for combining conditions

Command Palette & Navigation

Ctrl+Shift+P / F1Command Palette: run any command by name
Ctrl+PQuick Open a file by name (type : then a number to jump to a line)
Ctrl+GGo to line
Ctrl+Shift+O / Ctrl+TGo to symbol in file / in workspace
F12 / Alt+F12 / Shift+F12Go to definition / peek definition / find all references
F2Rename a symbol everywhere
Ctrl+.Quick fix and code actions
Alt+Left / Alt+RightGo back / forward through your cursor history
Ctrl+Shift+\Jump to the matching bracket

Editing Lines

Alt+Up / Alt+DownMove the line (or selection) up / down
Shift+Alt+Up / Shift+Alt+DownCopy the line up / down
Ctrl+Shift+KDelete the line
Ctrl+Enter / Ctrl+Shift+EnterInsert a line below / above
Ctrl+] / Ctrl+[Indent / outdent the line
Ctrl+/Toggle line comment
Shift+Alt+AToggle block comment
Ctrl+K Ctrl+XTrim trailing whitespace

Selection & Multiple Cursors

Ctrl+LSelect the current line
Shift+Alt+Right / LeftExpand / shrink the selection
Ctrl+DAdd the next occurrence of the selected text to the selection
Ctrl+Shift+LSelect every occurrence of the selected text
Alt+ClickAdd a cursor where you click
Ctrl+Alt+Up / Ctrl+Alt+DownAdd a cursor above / below
Shift+Alt+dragColumn (box) selection with the mouse
Ctrl+UUndo the last cursor action

Code Help, Formatting & Folding

Ctrl+SpaceTrigger suggestions
Ctrl+Shift+SpaceShow parameter hints
Shift+Alt+FFormat the whole document
Ctrl+K Ctrl+FFormat the selection
Ctrl+Shift+[ / Ctrl+Shift+]Fold / unfold the current region
Ctrl+K Ctrl+0 / Ctrl+K Ctrl+JFold all / unfold all
Ctrl+K Ctrl+C / Ctrl+K Ctrl+UAdd / remove line comment

Find & Replace

Ctrl+F / Ctrl+HFind / replace in the current file
F3 / Shift+F3Next / previous match
Alt+EnterSelect all matches of the current search
Alt+C / Alt+W / Alt+RMatch case / whole word / regular expression
Ctrl+Shift+F / Ctrl+Shift+HFind / replace across the workspace
editor.find.loopWrap around from the last match to the first (default true)
editor.find.seedSearchStringFromSelectionnever, always, selection: pre-fill the find box from the editor
editor.find.autoFindInSelectionnever, always, multiline: search only the selection

Files & Editors

Ctrl+N / Ctrl+O / Ctrl+K Ctrl+ONew file / open file / open folder
Ctrl+S / Ctrl+K S / Ctrl+Shift+SSave / save all / save as
Ctrl+WClose the current editor
Ctrl+K Ctrl+WClose all editors
Ctrl+Shift+TReopen the editor you just closed
Ctrl+TabSwitch between open editors
Ctrl+K EnterKeep a preview tab open
Ctrl+K P / Ctrl+K RCopy the file's path / reveal it in the Explorer

Layout, Views & Panels

Ctrl+B / Ctrl+JShow or hide the side bar / the bottom panel
Ctrl+Shift+E / F / G / D / XExplorer / Search / Source Control / Run and Debug / Extensions
Ctrl+` / Ctrl+Shift+M / Ctrl+Shift+UTerminal / Problems / Output
Ctrl+\ / Ctrl+1 / Ctrl+2Split the editor / focus editor group 1 / group 2
Ctrl+K Z / F11Zen Mode / full screen
Ctrl+K Ctrl+TColour theme picker

Run & Debug

F5 / Ctrl+F5 / Shift+F5Start debugging / run without debugging / stop
F9Toggle a breakpoint on the current line
F10 / F11 / Shift+F11Step over / step into / step out
Ctrl+Shift+YOpen the Debug Console

Keyboard-Related Settings

keyboard.dispatchcode (default) or keyCode: match shortcuts by physical key or by the character it types (matters on non-US layouts)
keyboard.mapAltGrToCtrlAlttrue: treat AltGr as Ctrl+Alt (default false)
workbench.commandPalette.preserveInputReopen the Command Palette with your last text (default false)
editor.multiCursorModifierKey for click-to-add-cursor: alt (default) or ctrlCmd

A Few Custom Shortcuts to Copy (my suggestions)

{ "key": "ctrl+alt+s", "command": "workbench.action.files.saveAll" }A one-step Save All
{ "key": "ctrl+alt+t", "command": "workbench.action.terminal.toggleTerminal" }A second way to toggle the terminal
{ "key": "ctrl+alt+f", "command": "editor.action.formatDocument", "when": "editorTextFocus" }Format with an easier chord
{ "key": "ctrl+shift+k", "command": "-editor.action.deleteLines" }Frees Ctrl+Shift+K if you want it for something else (match the original when if the removal has no effect)
A shortcut does nothing? Find out why
First look it up in the Keyboard Shortcuts editor (Ctrl+K Ctrl+S): a second command bound to the same keys, or a when condition that is false right now, is the usual cause. Then run Developer: Toggle Keyboard Shortcuts Troubleshooting and press the keys: the Output panel shows which command VS Code actually ran. In the terminal, many keys go to the shell, see the Terminal cheat sheet.
Chords: pressing Ctrl+K then waiting
Shortcuts that begin Ctrl+K are two-step chords. After the first press VS Code shows (Ctrl+K) was pressed. Waiting for second key of chord... in the status bar. Press Esc to cancel. Some chords need Ctrl held for the second key too, as in Ctrl+K Ctrl+S; others use a plain second key, as in Ctrl+K Z.