Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code list of keyboard shortcuts options

Visual Studio Code is highly customizable in its key bindings, especially when it comes to contextual bindings (using "when" to bind the same shortcut to different commands in different contexts).

I'm looking for a list of variables that can be used in those "when" conditions. (There is a great list of commands, but conditions are not listed there). I see the condition is a JavaScript expression that must evaluate to a boolean, but it is unclear what variables are in scope.

Can someone provide such a list?

like image 345
Dominik Schreiber Avatar asked Oct 07 '15 08:10

Dominik Schreiber


People also ask

How do I change keyboard shortcuts in Visual Studio?

On the menu bar, choose Tools > Options. Expand Environment, and then choose Keyboard. Optional: Filter the list of commands by entering all or part of the name of the command, without spaces, in the Show commands containing box. In the list, choose the command to which you want to assign a keyboard shortcut.

How do I create a keyboard shortcut in VS Code?

You can define a keyboard shortcut for any task. From the Command Palette (Ctrl+Shift+P), select Preferences: Open Keyboard Shortcuts File, bind the desired shortcut to the workbench.

How do I change the keyboard layout in Visual Studio code?

Customizing Shortcuts All keyboard shortcuts in VS Code can be customized via the User/keybindings. json file. To configure keyboard shortcuts the way you want, go to the menu under File > Preferences > Keyboard Shortcuts. This will open the Default Keyboard Shortcuts on the left and your User/keybindings.


3 Answers

These are hopefully all variables that can be used in when conditions:

editorFocus
editorHasMultipleSelections
editorHasSelection
editorLangId == 'name' // for example: editorLangId == 'typescript' 
editorTabMovesFocus
editorTextFocus
findWidgetVisible
globalMessageVisible
hasWordHighlights
inChangeAllMode
inDebugMode
inQuickOpen
inReferenceSearchEditor
inSnippetMode
markersNavigationVisible
parameterHintsVisible
peekDeclarationVisible
quickFixWidgetVisible
referenceSearchVisible
renameInputVisible
searchViewletVisible
suggestWidgetVisible
textCompareEditorVisible

You can concat them with && and invert them with !. For example

editorTextFocus && !editorTabMovesFocus 
like image 170
Wosi Avatar answered Oct 12 '22 13:10

Wosi


Updated. April 2019 (version 1.34)

List of all variables that can be used in when conditions in version 1.34:

acceptSuggestionOnEnter
accessibilityHelpWidgetVisible
activeEditor
activeEditorGroupEmpty
atEndOfWord
breadcrumbsActive
breadcrumbsPossible
breadcrumbsVisible
breakpointSelected
breakpointWidgetVisible
breakpointsFocused
callHierarchyVisible
commentEditorFocused
config.breadcrumbs.enabled
config.editor.stablePeek
config.editor.tabCompletion
config.emmet.triggerExpansionOnTab
config.gitlens.keymap
debugConfigurationType
debugState
debugType
dirtyDiffVisible
editorFocus
editorHasCallHierarchyProvider
editorHasCodeActionsProvider
editorHasCompletionItemProvider
editorHasDefinitionProvider
editorHasDocumentFormattingProvider
editorHasDocumentSelectionFormattingProvider
editorHasImplementationProvider
editorHasMultipleSelections
editorHasReferenceProvider
editorHasRenameProvider
editorHasSelection
editorHasSignatureHelpProvider
editorIsOpen
editorLangId
editorReadonly
editorTabMovesFocus
editorTextFocus
explorerResourceCut
explorerResourceIsFolder
explorerResourceIsRoot
explorerResourceMoveableToTrash
explorerResourceReadonly
explorerViewletFocus
explorerViewletVisible
expressionSelected
fileMatchFocus
fileMatchOrFolderMatchFocus
fileMatchOrMatchFocus
filesExplorerFocus
findInputFocussed
findWidgetVisible
firstMatchFocus
folderMatchFocus
gitlens:activeFileStatus
gitlens:canToggleCodeLens
gitlens:enabled
gitlens:key:,
gitlens:key:.
gitlens:key:escape
gitlens:key:left
gitlens:key:right
hasNextTabstop
hasOtherSuggestions
hasPrevTabstop
hasSearchResult
hasSnippetCompletions
hasWordHighlights
historyNavigationEnabled
historyNavigationWidget
inBreakpointWidget
inDebugMode
inDebugRepl
inEditorsPicker
inFilesPicker
inKeybindings
inKeybindingsSearch
inQuickOpen
inRecentFilesPicker
inReferenceSearchEditor
inSettingsEditor
inSettingsSearch
inSnippetMode
inViewsPicker
inZenMode
inputBoxFocus
inputFocus
interactivePlaygroundFocus
interfaceOverviewVisible
isDevelopment
isInDiffEditor
isInEmbeddedEditor
keybindingFocus
listFocus
listHasSelectionOrFocus
listSupportsMultiselect
markersNavigationVisible
matchFocus
messageVisible
multipleEditorGroups
notificationCenterVisible
notificationFocus
notificationToastsVisible
parameterHintsMultipleSignatures
parameterHintsVisible
problemFocus
problemsFilterFocus
problemsViewFocus
python.datascience.featureenabled
python.datascience.hascodecells
python.datascience.ownsSelection
reference-list.hasResult
referenceSearchTreeFocused
referenceSearchVisible
remoteFileDialogVisible
renameInputVisible
replaceActive
replaceInputBoxFocus
replaceInputFocussed
scmRepository
searchInputBoxFocus
searchViewletFocus
searchViewletVisible
settingsTocRowFocus
suggestWidgetMultipleSuggestions
suggestWidgetVisible
suggestionMakesTextEdit
supportedCodeAction
terminalFindWidgetFocused
terminalFindWidgetVisible
terminalFocus
terminalTextSelected
textCompareEditorVisible
textInputFocus
variablesFocused
watchExpressionsFocused
webviewFindWidgetVisible
workbench.explorer.openEditorsView.active
like image 28
Victor S. Avatar answered Oct 12 '22 13:10

Victor S.


The when clause documentation has been moved to when clause contexts.

But it is essentially the same info as was available before and does not provide much of a list of available contexts unfortunately.

Your best bet is to use the Developer: Inspect Context Keys command. See https://stackoverflow.com/a/65584576/836330 for more info on that command.


Intellisense for the when context is in v1.54, see Intellisense for Context Keys . Although right now I have to trigger it with Ctrl+Space, the intellisense doesn't seem to pop up just by typing some letters:

context key intellisense

like image 3
Mark Avatar answered Oct 12 '22 12:10

Mark