文章目录
- 官方文档
- when clause context(控制快捷键生效条件)
- 如果您的快捷绑定设置乱了,可以参考这里恢复出厂配置
- 本地查看:
官方文档
- Visual Studio Code Key Bindings
when clause context(控制快捷键生效条件)
使用when条件可以让你更加精细的配置快捷键
这样,同一个快捷键可以在编辑不同类型文件的时候执行不同的指令
when clause contexts | Visual Studio Code Extension API
Operator | Symbol | Example |
Equality | | |
Inequality | | |
Or | | |
And | | |
Not | | |
Matches | | |
Greater than | | |
Less than | | |
In | | |
如果您的快捷绑定设置乱了,可以参考这里恢复出厂配置
本地查看:
// 将键绑定放在此文件中以覆盖默认值auto[]
[
{
"key": "alt+t",
"command": "terminal.focus"
},
{
"key": "e",
"command": "",
"when": "editorTextFocus"
},
{
"key": "alt+e",
"command": "workbench.action.focusFirstEditorGroup"
},
{
"key": "ctrl+1",
"command": "workbench.action.focusFirstEditorGroup"
},
{
"key": "ctrl+v",
"command": "editor.action.clipboardPasteAction"
},
{
"key": "ctrl+v",
"command": "-editor.action.clipboardPasteAction"
},
{
"key": "ctrl+v",
"command": "workbench.action.terminal.paste",
"when": "terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+v",
"command": "-workbench.action.terminal.paste",
"when": "terminalFocus && terminalProcessSupported"
},
{
"key": "alt+oem_2",
"command": "workbench.action.openSettings"
},
{
"key": "ctrl+oem_comma",
"command": "-workbench.action.openSettings"
},
{
"key": "shift+alt+f",
"command": "toggleSuggestionDetails",
"when": "suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+space",
"command": "-toggleSuggestionDetails",
"when": "suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+n",
"command": "explorer.newFile"
},
{
"key": "ctrl+n",
"command": "-workbench.action.files.newUntitledFile"
},
{
"key": "alt+i",
"command": "editor.action.organizeImports",
"when": "editorTextFocus && !editorReadonly && supportedCodeAction =~ /(\\s|^)source\\.organizeImports\\b/"
},
{
"key": "alt+m",
"command": "workbench.panel.markers.view.focus"
},
{
"key": "ctrl+oem_period",
"command": "-settings.action.editFocusedSetting",
"when": "inSettingsSearch"
},
{
"key": "ctrl+oem_period",
"command": "-problems.action.showQuickFixes",
"when": "problemFocus"
},
{
"key": "alt+oem_period",
"command": "editor.action.quickFix",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+oem_period",
"command": "-editor.action.quickFix",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
},
{
"key": "alt+insert",
"command": "-workbench.action.files.newUntitledFile"
},
{
"key": "ctrl+k ctrl+f",
"command": "editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+k ctrl+f",
"command": "editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
},
{
"key": "alt+f",
"command": "editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
},
{
"key": "alt+right",
"command": "-workbench.action.navigateForward"
},
{
"key": "alt+right",
"command": "-workbench.action.terminal.focusNextPane",
"when": "terminalFocus && terminalProcessSupported"
},
{
"key": "alt+right",
"command": "-workbench.action.terminal.focusNext",
"when": "terminalFocus && terminalProcessSupported"
},
{
"key": "alt+right",
"command": "-workbench.action.nextEditor"
},
{
"key": "alt+right",
"command": "editor.action.revealDefinition",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
},
{
"key": "ctrl+alt+p",
"command": "workbench.panel.markers.view.focus"
},
{
"key": "ctrl+alt+f",
"command": "extension.cursorTip",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+enter",
"command": "-editor.action.insertLineAfter",
"when": "editorTextFocus && !editorReadonly && !suggestWidgetVisible"
},
{
"key": "ctrl+r",
"command": "-editor.action.startFindReplaceAction",
"when": "editorFocus || editorIsOpen"
},
{
"key": "ctrl+enter",
"command": "-extension.executeAREPLBlock",
"when": "editorTextFocus && editorLangId == 'python'"
},
{
"key": "ctrl+enter",
"command": "-jupyter.runcurrentcell",
"when": "editorTextFocus && jupyter.hascodecells && !editorHasSelection && !notebookEditorFocused"
},
{
"key": "ctrl+enter",
"command": "-breadcrumbs.revealFocused",
"when": "breadcrumbsActive && breadcrumbsVisible"
},
{
"key": "ctrl+enter",
"command": "-notebook.cell.insertCodeCellBelow",
"when": "notebookCellListFocused && !inputFocus"
},
{
"key": "ctrl+enter",
"command": "-debug.openBreakpointToSide",
"when": "breakpointsFocused"
},
{
"key": "ctrl+enter",
"command": "-editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus"
},
{
"key": "ctrl+enter",
"command": "-breadcrumbs.revealFocusedFromTreeAside",
"when": "breadcrumbsActive && breadcrumbsVisible && listFocus && !inputFocus"
},
{
"key": "ctrl+enter",
"command": "-explorer.openToSide",
"when": "explorerViewletFocus && explorerViewletVisible && !inputFocus"
},
{
"key": "ctrl+enter",
"command": "-lineBreakInsert",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+enter",
"command": "-openReferenceToSide",
"when": "listFocus && referenceSearchVisible && !inputFocus"
},
{
"key": "ctrl+enter",
"command": "-problems.action.openToSide",
"when": "problemFocus"
},
{
"key": "ctrl+enter",
"command": "-scm.acceptInput",
"when": "scmRepository"
},
{
"key": "ctrl+enter",
"command": "-search.action.openResultToSide",
"when": "fileMatchOrMatchFocus && searchViewletVisible"
},
{
"key": "ctrl+enter",
"command": "-workbench.action.submitComment",
"when": "commentEditorFocused"
},
{
"key": "ctrl+shift+oem_2",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+a",
"command": "-editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+a",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+k",
"command": "-git.pushTo",
"when": "!inDebugMode && !terminalFocus"
},
{
"key": "alt+k",
"command": "editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+shift+v",
"command": "-markdown.showPreview",
"when": "!notebookEditorFocused && editorLangId == 'markdown'"
},
{
"key": "ctrl+k v",
"command": "-markdown.showPreviewToSide",
"when": "!notebookEditorFocused && editorLangId == 'markdown'"
},
{
"key": "ctrl+k ctrl+v",
"command": "markdown.showPreviewToSide"
},
// {
// "key": "ctrl+v ctrl+2",
// "command": "markdown-preview-enhanced.openPreviewToTheSide",
// "when": "editorLangId == 'markdown'"
// },
{
"key": "ctrl+k v",
"command": "-markdown-preview-enhanced.openPreviewToTheSide",
"when": "editorLangId == 'markdown'"
},
{
"key": "alt+insert",
"command": "extension.javaGenerateUsingGui"
},
{
"key": "ctrl+shift+l",
"command": "editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+oem_plus",
"command": "editor.action.fontZoomIn"
},
{
"key": "ctrl+oem_minus",
"command": "editor.action.fontZoomOut"
},
{
"key": "ctrl+tab",
"command": "editor.action.indentLines",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "f3",
"command": "-editor.action.nextMatchFindAction",
"when": "editorFocus"
},
{
"key": "f3",
"command": "-workbench.action.terminal.findNext",
"when": "terminalFindFocused && terminalProcessSupported || terminalFocus && terminalProcessSupported"
},
{
"key": "alt+k alt+t",
"command": "workbench.action.quickOpenTerm"
},
{
"key": "enter",
"command": "-editor.action.replaceOne",
"when": "editorFocus && findWidgetVisible && replaceInputFocussed"
},
{
"key": "alt+enter",
"command": "acceptSelectedSuggestion",
"when": "acceptSuggestionOnEnter && suggestWidgetVisible && suggestionMakesTextEdit && textInputFocus"
},
{
"key": "enter",
"command": "-acceptSelectedSuggestion",
"when": "acceptSuggestionOnEnter && suggestWidgetVisible && suggestionMakesTextEdit && textInputFocus"
},
{
"key": "enter",
"command": "-selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "alt+s",
"command": "-markdown.extension.editing.toggleStrikethrough",
"when": "editorTextFocus && !editorReadonly && editorLangId == 'markdown'"
},
{
"key": "ctrl+shift+n",
"command": "explorer.newFolder"
},
{
"key": "ctrl+down",
"command": "-selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "down",
"command": "-selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "down",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "shift+space",
"command": "editor.action.cancelSelectionAnchor",
"when": "editorTextFocus && selectionAnchorSet"
},
{
"key": "ctrl+enter",
"command": "-editor.action.goToDeclaration",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+-",
"command": "editor.fold",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+alt+=",
"command": "editor.unfold",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+shift+r",
"command": "editor.action.rename",
"when": "editorHasRenameProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+v",
"command": "-notebook.cell.pasteAbove",
"when": "notebookEditorFocused && !inputFocus"
},
{
"key": "ctrl+shift+v",
"command": "-pythonPreview.showPreview",
"when": "editorLangId == 'python'"
},
{
"key": "ctrl+shift+v",
"command": "-editor.action.clipboardPasteAction",
"when": "config.latex-utilities.formattedPaste.useAsDefault && editorTextFocus && editorLangId == 'latex'"
},
{
"key": "ctrl+shift+v",
"command": "-workbench.action.terminal.paste",
"when": "terminalFocus && terminalProcessSupported"
},
{
"key": "ctrl+shift+v",
"command": "-markdown-preview-enhanced.openPreview",
"when": "editorLangId == 'markdown'"
},
{
"key": "ctrl+shift+v",
"command": "-latex-utilities.formattedPaste",
"when": "editorTextFocus && !config.latex-utilities.formattedPaste.useAsDefault && editorLangId == 'latex'"
},
{
"key": "ctrl+shift+v",
"command": "-html.showPreview",
"when": "editorLangId == 'html'"
},
{
"key": "ctrl+shift+v",
"command": "-markdown.extension.togglePreview",
"when": "!terminalFocus"
},
{
"key": "ctrl+; b",
"command": "-jupyter.insertCellBelow",
"when": "editorTextFocus && jupyter.hascodecells && !notebookEditorFocused"
},
{
"key": "ctrl+; s",
"command": "-jupyter.insertCellBelowPosition",
"when": "editorTextFocus && jupyter.hascodecells && !notebookEditorFocused"
},
{
"key": "ctrl+k ctrl+n",
"command": "jupyter.insertCellBelow"
},
{
"key": "ctrl+shift+enter",
"command": "-notebook.cell.insertCodeCellAbove",
"when": "notebookCellListFocused && !inputFocus"
},
{
"key": "f5",
"command": "notebook.cell.executeAndInsertBelow",
"when": "notebookCellExecutionState == 'idle' || notebookCellListFocused && notebookCellExecutionState == 'failed' || notebookCellListFocused && notebookCellType == 'markdown' || notebookCellExecutionState == 'succeeded' && notebookKernelCount > 0"
},
{
"key": "ctrl+v",
"command": "-markdown.extension.editing.paste",
"when": "editorHasSelection && editorTextFocus && editorLangId == 'markdown'"
},
{
"key": "ctrl+v",
"command": "-workbench.action.terminal.sendSequence",
"when": "terminalFocus && !accessibilityModeEnabled && terminalShellType == 'pwsh'"
},
{
"key": "f10",
"command": "editor.debug.action.runToCursor"
},
{
"key": "ctrl+k ctrl+u",
"command": "editor.unfoldAll",
"when": "editorTextFocus && foldingEnabled"
},
{
"key": "ctrl+k ctrl+e",
"command": "-keybindings.editor.defineWhenExpression",
"when": "inKeybindings && keybindingFocus"
},
{
"key": "ctrl+k ctrl+e",
"command": "revealFileInOS",
"when": "!editorFocus"
},
{
"key": "ctrl+l",
"command": "better-line-select.downward",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+a",
"command": "jupyter.runallcells"
},
{
"key": "ctrl+alt+b",
"command": "jupyter.runcell"
},
{
"key": "ctrl+alt+m",
"command": "jupyter.runcurrentcell",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !jupyter.havenativecells && !notebookEditorFocused"
},
{
"key": "ctrl+enter",
"command": "-jupyter.runcurrentcell",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !jupyter.havenativecells && !notebookEditorFocused"
},
{
"key": "f5",
"command": "jupyter.notebookeditor.keybind.executeCell",
"when": "config.jupyter.enableKeyboardShortcuts && notebookCellListFocused && notebookCellType == 'code' && notebookType == 'jupyter-notebook' || config.jupyter.enableKeyboardShortcuts && editorTextFocus && inputFocus && notebookEditorFocused && notebookType == 'jupyter-notebook'"
},
{
"key": "ctrl+enter",
"command": "-jupyter.notebookeditor.keybind.executeCell",
"when": "config.jupyter.enableKeyboardShortcuts && notebookCellListFocused && notebookCellType == 'code' && notebookType == 'jupyter-notebook' || config.jupyter.enableKeyboardShortcuts && editorTextFocus && inputFocus && notebookEditorFocused && notebookType == 'jupyter-notebook'"
},
{
"key": "ctrl+enter",
"command": "editor.action.insertLineAfter",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+enter",
"command": "-editor.action.insertLineAfter",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "f5",
"command": "notebook.cell.quitEdit",
"when": "config.jupyter.enableKeyboardShortcuts && inputFocus && notebookEditorFocused && !editorHasMultipleSelections && !editorHasSelection && !editorHoverVisible && notebookCellType == 'markup'"
},
{
"key": "ctrl+enter",
"command": "-notebook.cell.quitEdit",
"when": "config.jupyter.enableKeyboardShortcuts && inputFocus && notebookEditorFocused && !editorHasMultipleSelections && !editorHasSelection && !editorHoverVisible && notebookCellType == 'markup'"
},
{
"key": "ctrl+k enter",
"command": "jupyter.runcurrentcellandaddbelow",
"when": "editorTextFocus && jupyter.hascodecells && !editorHasSelection && !notebookEditorFocused"
},
{
"key": "ctrl+oem_1 u",
"command": "-jupyter.moveCellsUp",
"when": "editorTextFocus && jupyter.hascodecells && !notebookEditorFocused"
},
{
"key": "ctrl+k ctrl+c",
"command": "jupyter.runcurrentcell",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !jupyter.havenativecells && !notebookEditorFocused"
},
{
"key": "ctrl+k ctrl+right",
"command": "jupyter.runcurrentcellandallbelow.palette"
},
{
"key": "ctrl+k ctrl+j",
"command": "jupyter.insertCellBelowPosition",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !notebookEditorFocused"
},
{
"key": "ctrl+oem_1 s",
"command": "-jupyter.insertCellBelowPosition",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !notebookEditorFocused"
},
{
"key": "ctrl+k ctrl+p",
"command": "jupyter.insertCellBelowPosition",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !notebookEditorFocused"
},
{
"key": "ctrl+k ctrl+t",
"command": "jupyter.runcurrentcelladvance",
"when": "editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !notebookEditorFocused"
},
{
"key": "ctrl+k ctrl+t",
"command": "jupyter.runallcellsabove.palette"
},
{
"key": "ctrl+shift+t",
"command": "workbench.action.showCommands"
},
{
"key": "ctrl+shift+p",
"command": "-workbench.action.showCommands"
},
{
"key": "ctrl+shift+p",
"command": "workbench.action.showCommands"
},
{
"key": "ctrl+k ctrl+f",
"command": "actions.find",
"when": "editorFocus || editorIsOpen"
},
{
"key": "ctrl+k ctrl+a",
"command": "editor.action.selectAll"
},
{
"key": "alt+q",
"command": "editor.action.showHover",
"when": "editorTextFocus"
},
{
"key": "ctrl+w",
"command": "workbench.action.closeActiveEditor"
},
{
"key": "ctrl+k ctrl+a",
"command": "jupyter.runallcellsabove.palette"
},
{
"key": "alt+enter",
"command": "editor.action.quickFix",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+1",
"command": "-openInDefaultBrowser.openInDefaultBrowser",
"when": "resourceExtname == '.pdf' || resourceLangId == 'html' || resourceLangId == 'xml'"
},
{
"key": "ctrl+shift+b",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+b",
"command": "-workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+r",
"command": "-workbench.action.reloadWindow",
"when": "isDevelopment"
},
{
"key": "ctrl+k ctrl+r",
"command": "workbench.action.openRecent"
},
{
"key": "ctrl+r",
"command": "-workbench.action.openRecent"
},
{
"key": "ctrl+a",
"command": "-extension.vim_ctrl+a",
"when": "editorTextFocus && vim.active && vim.use<C-a> && !inDebugRepl"
},
{
"key": "ctrl+k ctrl+c",
"command": "editor.action.clipboardCopyAction"
},
{
"key": "ctrl+k ctrl+p",
"command": "polacode.activate"
},
{
"key": "ctrl+x",
"command": "-extension.vim_ctrl+x",
"when": "editorTextFocus && vim.active && vim.use<C-x> && !inDebugRepl"
},
{
"key": "backspace",
"command": "extension.vim_backspace",
"when": "editorTextFocus && vim.active && !inDebugRepl"
},
{
"key": "ctrl+y",
"command": "-extension.vim_ctrl+y",
"when": "editorTextFocus && vim.active && vim.use<C-y> && !inDebugRepl"
},
{
"key": "ctrl+c",
"command": "-extension.vim_ctrl+c",
"when": "editorTextFocus && vim.active && vim.overrideCtrlC && vim.use<C-c> && !inDebugRepl"
},
{
"key": "ctrl+l",
"command": "expandLineSelection",
},
{
"key": "ctrl+alt+d",
"command": "editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "ctrl+d",
"command": "-editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "ctrl+j",
"command": "cursorDown",
"when": "textInputFocus"
},
{
"key": "ctrl+alt+t",
"command": "workbench.action.closePanel"
},
{
"key": "ctrl+shift+p",
"command": "-workbench.action.quickOpenNavigatePreviousInFilePicker",
"when": "inFilesPicker && inQuickOpen"
},
{
"key": "tab",
"command": "-extension.vim_tab",
"when": "editorFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'"
},
{
"key": "ctrl+shift+o",
"command": "outline.focus"
},
{
"key": "ctrl+j",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+alt+u",
"command": "-platformio-ide.upload"
},
{
"key": "ctrl+v",
"command": "paste",
"when": "filesExplorerFocus"
}
]