VS code
https://code.visualstudio.com/docs/customization/keybindings
Visual Studio Code lets you perform most tasks directly from the keyboard. This page lists out the default bindings and describes how you can update them.
Note: If you visit this page on a Mac, you will see the key bindings for the Mac. If you visit using Windows or Linux, you will see the keys for that OS. If you need the key binding for another OS, hover your mouse over the key you are interested in.
Note: The following keys are rendered assuming a standard US keyboard layout. If you use a different keyboard layout, please read below.
Key | Command | Command id |
---|---|---|
Ctrl+X | Cut line (empty selection) | editor.action.clipboardCutAction |
Ctrl+C | Copy line (empty selection) | editor.action.clipboardCopyAction |
Ctrl+Shift+K | Delete Line | editor.action.deleteLines |
Ctrl+Enter | Insert Line Below | editor.action.insertLineAfter |
Ctrl+Shift+Enter | Insert Line Above | editor.action.insertLineBefore |
Alt+Down | Move Line Down | editor.action.moveLinesDownAction |
Alt+Up | Move Line Up | editor.action.moveLinesUpAction |
Shift+Alt+Down | Copy Line Down | editor.action.copyLinesDownAction |
Shift+Alt+Up | Copy Line Up | editor.action.copyLinesUpAction |
Ctrl+D | Add Selection To Next Find Match | editor.action.addSelectionToNextFindMatch |
Ctrl+K Ctrl+D | Move Last Selection To Next Find Match | editor.action.moveSelectionToNextFindMatch |
Ctrl+U | Undo last cursor operation | cursorUndo |
Shift+Alt+I | Insert cursor at end of each line selected | editor.action.insertCursorAtEndOfEachLineSelected |
Ctrl+Shift+L | Select all occurrences of current selection | editor.action.selectHighlights |
Ctrl+F2 | Select all occurrences of current word | editor.action.changeAll |
Ctrl+I | Select current line | expandLineSelection |
Ctrl+Alt+Down | Insert Cursor Below | editor.action.insertCursorBelow |
Ctrl+Alt+Up | Insert Cursor Above | editor.action.insertCursorAbove |
Ctrl+Shift+\ | Jump to matching bracket | editor.action.jumpToBracket |
Ctrl+] | Indent Line | editor.action.indentLines |
Ctrl+[ | Outdent Line | editor.action.outdentLines |
Home | Go to Beginning of Line | cursorHome |
End | Go to End of Line | cursorEnd |
Ctrl+End | Go to End of File | cursorBottom |
Ctrl+Home | Go to Beginning of File | cursorTop |
Ctrl+Down | Scroll Line Down | scrollLineDown |
Ctrl+Up | Scroll Line Up | scrollLineUp |
Alt+PageDown | Scroll Page Down | scrollPageDown |
Alt+PageUp | Scroll Page Up | scrollPageUp |
Ctrl+Shift+[ | Fold (collapse) region | editor.fold |
Ctrl+Shift+] | Unfold (uncollapse) region | editor.unfold |
Ctrl+K Ctrl+[ | Fold (collapse) all subregions | editor.foldRecursively |
Ctrl+K Ctrl+] | Unfold (uncollapse) all subregions | editor.unfoldRecursively |
Ctrl+K Ctrl+0 | Fold (collapse) all regions | editor.foldAll |
Ctrl+K Ctrl+J | Unfold (uncollapse) all regions | editor.unfoldAll |
Ctrl+K Ctrl+C | Add Line Comment | editor.action.addCommentLine |
Ctrl+K Ctrl+U | Remove Line Comment | editor.action.removeCommentLine |
Ctrl+/ | Toggle Line Comment | editor.action.commentLine |
Shift+Alt+A | Toggle Block Comment | editor.action.blockComment |
Ctrl+F | Find | actions.find |
Ctrl+H | Replace | editor.action.startFindReplaceAction |
F3 | Find Next | editor.action.nextMatchFindAction |
Shift+F3 | Find Previous | editor.action.previousMatchFindAction |
Alt+Enter | Select All Occurences of Find Match | editor.action.selectAllMatches |
Alt+C | Toggle Find Case Sensitive | toggleFindCaseSensitive |
Alt+R | Toggle Find Regex | toggleFindRegex |
Alt+W | Toggle Find Whole Word | toggleFindWholeWord |
Ctrl+M | Toggle Use of Tab Key for Setting Focus | editor.action.toggleTabFocusMode |
unassigned | Toggle Render Whitespace | toggleRenderWhitespace |
Key | Command | Command id |
---|---|---|
Ctrl+Space | Trigger Suggest | editor.action.triggerSuggest |
Ctrl+Shift+Space | Trigger Parameter Hints | editor.action.triggerParameterHints |
Shift+Alt+F | Format Code | editor.action.format |
F12 | Go to Definition | editor.action.goToDeclaration |
Alt+F12 | Peek Definition | editor.action.previewDeclaration |
Ctrl+K F12 | Open Definition to the Side | editor.action.openDeclarationToTheSide |
Ctrl+. | Quick Fix | editor.action.quickFix |
Shift+F12 | Show References | editor.action.referenceSearch.trigger |
F2 | Rename Symbol | editor.action.rename |
Ctrl+Shift+. | Replace with Next Value | editor.action.inPlaceReplace.down |
Ctrl+Shift+, | Replace with Previous Value | editor.action.inPlaceReplace.up |
Shift+Alt+Right | Expand AST Select | editor.action.smartSelect.grow |
Shift+Alt+Left | Shrink AST Select | editor.action.smartSelect.shrink |
Ctrl+K Ctrl+X | Trim Trailing Whitespace | editor.action.trimTrailingWhitespace |
Ctrl+K M | Change Language Mode | workbench.action.editor.changeLanguageMode |
Key | Command | Command id |
---|---|---|
Ctrl+T | Show All Symbols | workbench.action.showAllSymbols |
Ctrl+G | Go to Line... | workbench.action.gotoLine |
Ctrl+P | Go to File..., Quick Open | workbench.action.quickOpen |
Ctrl+Shift+O | Go to Symbol... | workbench.action.gotoSymbol |
Ctrl+Shift+M | Show Problems | workbench.actions.view.problems |
F8 | Go to Next Error or Warning | editor.action.marker.next |
Shift+F8 | Go to Previous Error or Warning | editor.action.marker.prev |
Ctrl+Shift+P | Show All Commands | workbench.action.showCommands |
Ctrl+Shift+Tab | Navigate Editor Group History | workbench.action.openPreviousRecentlyUsedEditorInGroup |
Alt+Left | Go Back | workbench.action.navigateBack |
Alt+Right | Go Forward | workbench.action.navigateForward |
Key | Command | Command id |
---|---|---|
Ctrl+Shift+N | New Window | workbench.action.newWindow |
Ctrl+W | Close Window | workbench.action.closeWindow |
Ctrl+F4 | Close Editor | workbench.action.closeActiveEditor |
Ctrl+K F | Close Folder | workbench.action.closeFolder |
unassigned | Cycle Between Editor Groups | workbench.action.navigateEditorGroups |
Ctrl+\ | Split Editor | workbench.action.splitEditor |
Ctrl+1 | Focus into Left Editor Group | workbench.action.focusFirstEditorGroup |
Ctrl+2 | Focus into Side Editor Group | workbench.action.focusSecondEditorGroup |
Ctrl+3 | Focus into Right Editor Group | workbench.action.focusThirdEditorGroup |
Ctrl+K Ctrl+Left | Focus into Editor Group on the Left | workbench.action.focusPreviousGroup |
Ctrl+K Ctrl+Right | Focus into Editor Group on the Right | workbench.action.focusNextGroup |
Ctrl+K Left | Move Active Editor Group Left | workbench.action.moveActiveEditorGroupLeft |
Ctrl+K Right | Move Active Editor Group Right | workbench.action.moveActiveEditorGroupRight |
Key | Command | Command id |
---|---|---|
Ctrl+N | New File | workbench.action.files.newUntitledFile |
Ctrl+O | Open File... | workbench.action.files.openFile |
Ctrl+S | Save | workbench.action.files.save |
unassigned | Save All | workbench.action.files.saveAll |
Ctrl+Shift+S | Save As... | workbench.action.files.saveAs |
Ctrl+F4 | Close | workbench.action.closeActiveEditor |
unassigned | Close Others | workbench.action.closeOtherEditors |
Ctrl+K W | Close Group | workbench.action.closeEditorsInGroup |
unassigned | Close Other Groups | workbench.action.closeEditorsInOtherGroups |
unassigned | Close Group to Left | workbench.action.closeEditorsToTheLeft |
unassigned | Close Group to Right | workbench.action.closeEditorsToTheRight |
Ctrl+K Ctrl+W | Close All | workbench.action.closeAllEditors |
Ctrl+K Enter | Keep Open | workbench.action.keepEditor |
Ctrl+Tab | Open Next | workbench.action.openNextRecentlyUsedEditorInGroup |
Ctrl+Shift+Tab | Open Previous | workbench.action.openPreviousRecentlyUsedEditorInGroup |
Ctrl+K P | Copy Path of Active File | workbench.action.files.copyPathOfActiveFile |
Ctrl+K R | Reveal Active File in Windows | workbench.action.files.revealActiveFileInWindows |
Ctrl+K O | Show Opened File in New Window | workbench.action.files.showOpenedFileInNewWindow |
unassigned | Compare Opened File With | workbench.files.action.compareFileWith |
Key | Command | Command id |
---|---|---|
F11 | Toggle Full Screen | workbench.action.toggleFullScreen |
Ctrl+= | Zoom in | workbench.action.zoomIn |
Ctrl+- | Zoom out | workbench.action.zoomOut |
unassigned | Reset Zoom | workbench.action.zoomReset |
Ctrl+B | Toggle Sidebar Visibility | workbench.action.toggleSidebarVisibility |
Ctrl+Shift+D | Show Debug | workbench.view.debug |
Ctrl+Shift+E | Show Explorer / Toggle Focus | workbench.view.explorer |
Ctrl+Shift+G | Show Git | workbench.view.git |
Ctrl+Shift+F | Show Search | workbench.view.search |
Ctrl+Shift+H | Replace in Files | workbench.action.replaceInFiles |
Ctrl+Shift+X | Show Extensions | workbench.view.extensions |
Ctrl+Shift+J | Toggle Search Details | workbench.action.search.toggleQueryDetails |
Ctrl+Shift+C | Open New Command Prompt | workbench.action.terminal.openNativeConsole |
Ctrl+Shift+U | Show Output | workbench.action.output.toggleOutput |
Ctrl+Shift+V | Toggle Markdown Preview | markdown.showPreview |
Ctrl+K V | Open Preview to the Side | markdown.showPreviewToSide |
Ctrl+` | Toggle Integrated Terminal | workbench.action.terminal.toggleTerminal |
Key | Command | Command id |
---|---|---|
unassigned | Open User Settings | workbench.action.openGlobalSettings |
unassigned | Open Workspace Settings | workbench.action.openWorkspaceSettings |
unassigned | Open Keyboard Shortcuts | workbench.action.openGlobalKeybindings |
unassigned | Open User Snippets | workbench.action.openSnippets |
unassigned | Select Color Theme | workbench.action.selectTheme |
unassigned | Configure Display Language | workbench.action.configureLocale |
Key | Command | Command id |
---|---|---|
F9 | Toggle Breakpoint | editor.debug.action.toggleBreakpoint |
F5 | Continue | workbench.action.debug.continue |
F5 | Pause | workbench.action.debug.start |
F11 | Step Into | workbench.action.debug.stepInto |
Shift+F11 | Step Out | workbench.action.debug.stepOut |
F10 | Step Over | workbench.action.debug.stepOver |
Shift+F5 | Stop | workbench.action.debug.stop |
Ctrl+K Ctrl+I | Show Hover | editor.action.showHover |
Key | Command | Command id |
---|---|---|
Ctrl+Shift+B | Run Build Task | workbench.action.tasks.build |
unassigned | Run Test Task | workbench.action.tasks.test |
Key | Command | Command id |
---|---|---|
unassigned | Install Extension | workbench.extensions.action.installExtension |
unassigned | Show Installed Extensions | workbench.extensions.action.showInstalledExtensions |
unassigned | Show Outdated Extensions | workbench.extensions.action.listOutdatedExtensions |
unassigned | Show Recommended Extensions | workbench.extensions.action.showRecommendedExtensions |
unassigned | Show Popular Extensions | workbench.extensions.action.showPopularExtensions |
All keyboard shortcuts in VS Code can be customized via the User/keybindings.json
file.
Default Keyboard Shortcuts
on the left and your User/keybindings.json
file where you can overwrite the default bindings on the right.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.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. E.g.: ctrl+k ctrl+c.
When a key is pressed:
key
and in terms of when
, is accepted.command
set, the command
is executed.The additional User/keybindings.json
rules are appended at runtime to the bottom of the default rules, thus allowing them to overwrite the default rules. The User/keybindings.json
file is watched by VS Code so editing it while VS Code is running will update the rules at runtime.
The key
is made up of modifiers and the key itself.
The following modifiers are accepted:
OS | Modifiers |
---|---|
OS X | ctrl+, shift+, alt+, cmd+ |
Windows | ctrl+, shift+, alt+, win+ |
Linux | ctrl+, shift+, alt+, meta+ |
The following keys are accepted:
VS Code gives you fine control over when your key bindings are enabled through the optional when
clause. If you key binding doesn't have a when
clause, the key binding is globally available at all times.
Below are the some of the possible when
clause contexts which evaluate to Boolean true/false:
Context name | True when |
---|---|
Editor contexts | |
editorFocus | An editor has focus, either the text or a widget. |
editorTextFocus | The text in an editor has focus (cursor is blinking). |
editorHasSelection | Text is selected in the editor. |
editorHasMultipleSelections | Multiple regions of text are selected (multiple cursors). |
editorReadOnly | The editor is read only. |
editorLangId | True when the editor's associated language Id matches. Example: "editorLangId == typescript" . |
Mode contexts | |
inDebugMode | A debug session is running. |
inSnippetMode | The editor is in snippet mode. |
inQuickOpen | The Quick Open dropdown has focus. |
Editor widget contexts | |
findWidgetVisible | Editor Find widget is visible. |
suggestWidgetVisible | Suggestion widget (IntelliSense) is visible. |
suggestWidgetMultipleSuggestions | Multiple suggestions are displayed. |
renameInputVisible | Rename input text box is visible. |
referenceSearchVisible | Find All References peek window is open. |
inReferenceSearchEditor | The Find All References peek window editor has focus. |
config.editor.stablePeek | Keep peek editors open (controlled by editor.stablePeek setting). |
quickFixWidgetVisible | Quick Fix widget is visible. |
parameterHintsVisible | Parameter hints are visible (controlled by editor.parameterHints setting). |
parameterHintsMultipleSignatures | Multiple parameter hints are displayed. |
Integrated terminal contexts | |
terminalFocus | An integrated terminal has focus. |
Global UI contexts | |
resourceLangId | True when the Explorer or editor title language Id matches. Example: "resourceLangId == markdown" |
globalMessageVisible | Message box is visible at the top of VS Code. |
searchViewletVisible | Search view is open. |
replaceActive | Search view Replace text box is open. |
The list above isn't exhaustive and you may see some when
contexts for specific VS Code UI in the Default Keyboard Shortcuts
.
You can write a key binding rule that targets the removal of a specific default key binding. With the keybindings.json
, it was always possible to redefine all the key bindings of VS Code, but it can be very difficult to make a small tweak, especially around overloaded keys, such as Tab or Escape. To remove a specific key binding, simply add a -
to the command
and the rule will be a removal rule.
Here is an example:
// In Default Keyboard Shortcuts
...
{ "key": "tab", "command": "tab", "when": ... },
{ "key": "tab", "command": "editor.emmet.action.expandAbbreviation", "when": ... },
{ "key": "tab", "command": "jumpToNextSnippetPlaceholder", "when": ... },
{ "key": "tab", "command": "acceptQuickFixSuggestion", "when": ... },
{ "key": "tab", "command": "acceptSelectedSuggestion", "when": ... },
...
// To remove the second rule, for example, add in keybindings.json:
{ "key": "tab", "command": "-editor.emmet.action.expandAbbreviation" }