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.jsonPreferences: Open Default Keyboard Shortcuts (JSON)Command Palette: read-only list of every default bindingCopy Command IDRight-click a row in the editor: gives the command ID to use in keybindings.jsonHelp > Keyboard Shortcuts ReferenceOpens the official printable PDF of the defaultsDeveloper: Toggle Keyboard Shortcuts TroubleshootingLogs each pressed shortcut and the command it ran, in the Output panelkeybindings.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 chordargsExtra input for a command, e.g. { "text": "ls\u000D" } for workbench.action.terminal.sendSequence// commentskeybindings.json accepts comments, like settings.jsonKey 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–numpad9editorTextFocusTrue when the text editor has focusterminalFocusTrue when the integrated terminal has focus!editorReadonlyTrue when the editor is not read-onlyeditorLangId == pythonTrue only in one languageresourceExtname == .mdTrue for files with that extension&& || ! =~AND, OR, NOT, and regular-expression match, for combining conditionsCommand Palette & Navigation
Ctrl+Shift+P / F1Command Palette: run any command by nameCtrl+PQuick Open a file by name (type : then a number to jump to a line)Ctrl+GGo to lineCtrl+Shift+O / Ctrl+TGo to symbol in file / in workspaceF12 / Alt+F12 / Shift+F12Go to definition / peek definition / find all referencesF2Rename a symbol everywhereCtrl+.Quick fix and code actionsAlt+Left / Alt+RightGo back / forward through your cursor historyCtrl+Shift+\Jump to the matching bracketEditing Lines
Alt+Up / Alt+DownMove the line (or selection) up / downShift+Alt+Up / Shift+Alt+DownCopy the line up / downCtrl+Shift+KDelete the lineCtrl+Enter / Ctrl+Shift+EnterInsert a line below / aboveCtrl+] / Ctrl+[Indent / outdent the lineCtrl+/Toggle line commentShift+Alt+AToggle block commentCtrl+K Ctrl+XTrim trailing whitespaceSelection & Multiple Cursors
Ctrl+LSelect the current lineShift+Alt+Right / LeftExpand / shrink the selectionCtrl+DAdd the next occurrence of the selected text to the selectionCtrl+Shift+LSelect every occurrence of the selected textAlt+ClickAdd a cursor where you clickCtrl+Alt+Up / Ctrl+Alt+DownAdd a cursor above / belowShift+Alt+dragColumn (box) selection with the mouseCtrl+UUndo the last cursor actionCode Help, Formatting & Folding
Ctrl+SpaceTrigger suggestionsCtrl+Shift+SpaceShow parameter hintsShift+Alt+FFormat the whole documentCtrl+K Ctrl+FFormat the selectionCtrl+Shift+[ / Ctrl+Shift+]Fold / unfold the current regionCtrl+K Ctrl+0 / Ctrl+K Ctrl+JFold all / unfold allCtrl+K Ctrl+C / Ctrl+K Ctrl+UAdd / remove line commentFind & Replace
Ctrl+F / Ctrl+HFind / replace in the current fileF3 / Shift+F3Next / previous matchAlt+EnterSelect all matches of the current searchAlt+C / Alt+W / Alt+RMatch case / whole word / regular expressionCtrl+Shift+F / Ctrl+Shift+HFind / replace across the workspaceeditor.find.loopWrap around from the last match to the first (default true)editor.find.seedSearchStringFromSelectionnever, always, selection: pre-fill the find box from the editoreditor.find.autoFindInSelectionnever, always, multiline: search only the selectionFiles & Editors
Ctrl+N / Ctrl+O / Ctrl+K Ctrl+ONew file / open file / open folderCtrl+S / Ctrl+K S / Ctrl+Shift+SSave / save all / save asCtrl+WClose the current editorCtrl+K Ctrl+WClose all editorsCtrl+Shift+TReopen the editor you just closedCtrl+TabSwitch between open editorsCtrl+K EnterKeep a preview tab openCtrl+K P / Ctrl+K RCopy the file's path / reveal it in the ExplorerLayout, Views & Panels
Ctrl+B / Ctrl+JShow or hide the side bar / the bottom panelCtrl+Shift+E / F / G / D / XExplorer / Search / Source Control / Run and Debug / ExtensionsCtrl+` / Ctrl+Shift+M / Ctrl+Shift+UTerminal / Problems / OutputCtrl+\ / Ctrl+1 / Ctrl+2Split the editor / focus editor group 1 / group 2Ctrl+K Z / F11Zen Mode / full screenCtrl+K Ctrl+TColour theme pickerRun & Debug
F5 / Ctrl+F5 / Shift+F5Start debugging / run without debugging / stopF9Toggle a breakpoint on the current lineF10 / F11 / Shift+F11Step over / step into / step outCtrl+Shift+YOpen the Debug ConsoleKeyboard-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 ctrlCmdA 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.