Built-in Commands
This document lists a subset of Visual Studio Code commands that you might use with vscode.commands.executeCommand
API.
Read the Commands guide for how to use the commands API.
The following is a sample of how to open a new folder in VS Code:
let uri = Uri.file('/some/path/to/folder');
let success = await commands.executeCommand('vscode.openFolder', uri);
Note: You can review the full set of VS Code commands via the Keyboard Shortcuts editor File > Preferences > Keyboard Shortcuts. The Keyboard Shortcuts editor lists all commands built into VS Code or contributed by extensions, along with their keybindings and visibility when clauses.
Commands
vscode.executeDataToNotebook
- Invoke notebook serializer
- notebookType - A notebook type
- data - Bytes to convert to data
- (returns) - Notebook Data
vscode.executeNotebookToData
- Invoke notebook serializer
- notebookType - A notebook type
- NotebookData - Notebook data to convert to bytes
- (returns) - Bytes
notebook.selectKernel
- Trigger kernel picker for specified notebook editor widget
- options - Select kernel options
- (returns) - no result
interactive.open
- Open interactive window and return notebook editor and input URI
- showOptions - Show Options
- resource - Interactive resource Uri
- controllerId - Notebook controller Id
- title - Interactive editor title
- (returns) - Notebook and input URI
vscode.editorChat.start
- Invoke a new editor chat session
- Run arguments -
- (returns) - no result
vscode.executeDocumentHighlights
- Execute document highlight provider.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of DocumentHighlight-instances.
vscode.executeDocumentSymbolProvider
- Execute document symbol provider.
- uri - Uri of a text document
- (returns) - A promise that resolves to an array of SymbolInformation and DocumentSymbol instances.
vscode.executeFormatDocumentProvider
- Execute document format provider.
- uri - Uri of a text document
- options - Formatting options
- (returns) - A promise that resolves to an array of TextEdits.
vscode.executeFormatRangeProvider
- Execute range format provider.
- uri - Uri of a text document
- range - A range in a text document
- options - Formatting options
- (returns) - A promise that resolves to an array of TextEdits.
vscode.executeFormatOnTypeProvider
- Execute format on type provider.
- uri - Uri of a text document
- position - A position in a text document
- ch - Trigger character
- options - Formatting options
- (returns) - A promise that resolves to an array of TextEdits.
vscode.executeDefinitionProvider
- Execute all definition providers.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of Location or LocationLink instances.
vscode.executeTypeDefinitionProvider
- Execute all type definition providers.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of Location or LocationLink instances.
vscode.executeDeclarationProvider
- Execute all declaration providers.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of Location or LocationLink instances.
vscode.executeImplementationProvider
- Execute all implementation providers.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of Location or LocationLink instances.
vscode.executeReferenceProvider
- Execute all reference providers.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of Location-instances.
vscode.executeHoverProvider
- Execute all hover providers.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of Hover-instances.
vscode.executeSelectionRangeProvider
- Execute selection range provider.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of ranges.
vscode.executeWorkspaceSymbolProvider
- Execute all workspace symbol providers.
- query - Search string
- (returns) - A promise that resolves to an array of SymbolInformation-instances.
vscode.prepareCallHierarchy
- Prepare call hierarchy at a position inside a document
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of CallHierarchyItem-instances
vscode.provideIncomingCalls
- Compute incoming calls for an item
- item - A call hierarchy item
- (returns) - A promise that resolves to an array of CallHierarchyIncomingCall-instances
vscode.provideOutgoingCalls
- Compute outgoing calls for an item
- item - A call hierarchy item
- (returns) - A promise that resolves to an array of CallHierarchyOutgoingCall-instances
vscode.prepareRename
- Execute the prepareRename of rename provider.
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to a range and placeholder text.
vscode.executeDocumentRenameProvider
- Execute rename provider.
- uri - Uri of a text document
- position - A position in a text document
- newName - The new symbol name
- (returns) - A promise that resolves to a WorkspaceEdit.
vscode.executeLinkProvider
- Execute document link provider.
- uri - Uri of a text document
- linkResolveCount - (optional) Number of links that should be resolved, only when links are unresolved.
- (returns) - A promise that resolves to an array of DocumentLink-instances.
vscode.provideDocumentSemanticTokensLegend
- Provide semantic tokens legend for a document
- uri - Uri of a text document
- (returns) - A promise that resolves to SemanticTokensLegend.
vscode.provideDocumentSemanticTokens
- Provide semantic tokens for a document
- uri - Uri of a text document
- (returns) - A promise that resolves to SemanticTokens.
vscode.provideDocumentRangeSemanticTokensLegend
- Provide semantic tokens legend for a document range
- uri - Uri of a text document
- range - (optional) A range in a text document
- (returns) - A promise that resolves to SemanticTokensLegend.
vscode.provideDocumentRangeSemanticTokens
- Provide semantic tokens for a document range
- uri - Uri of a text document
- range - A range in a text document
- (returns) - A promise that resolves to SemanticTokens.
vscode.executeCompletionItemProvider
- Execute completion item provider.
- uri - Uri of a text document
- position - A position in a text document
- triggerCharacter - (optional) Trigger completion when the user types the character, like
,
or(
- itemResolveCount - (optional) Number of completions to resolve (too large numbers slow down completions)
- (returns) - A promise that resolves to a CompletionList-instance.
vscode.executeSignatureHelpProvider
- Execute signature help provider.
- uri - Uri of a text document
- position - A position in a text document
- triggerCharacter - (optional) Trigger signature help when the user types the character, like
,
or(
- (returns) - A promise that resolves to SignatureHelp.
vscode.executeCodeLensProvider
- Execute code lens provider.
- uri - Uri of a text document
- itemResolveCount - (optional) Number of lenses that should be resolved and returned. Will only return resolved lenses, will impact performance
- (returns) - A promise that resolves to an array of CodeLens-instances.
vscode.executeCodeActionProvider
- Execute code action provider.
- uri - Uri of a text document
- rangeOrSelection - Range in a text document. Some refactoring provider requires Selection object.
- kind - (optional) Code action kind to return code actions for
- itemResolveCount - (optional) Number of code actions to resolve (too large numbers slow down code actions)
- (returns) - A promise that resolves to an array of Command-instances.
vscode.executeDocumentColorProvider
- Execute document color provider.
- uri - Uri of a text document
- (returns) - A promise that resolves to an array of ColorInformation objects.
vscode.executeColorPresentationProvider
- Execute color presentation provider.
- color - The color to show and insert
- context - Context object with uri and range
- (returns) - A promise that resolves to an array of ColorPresentation objects.
vscode.executeInlayHintProvider
- Execute inlay hints provider
- uri - Uri of a text document
- range - A range in a text document
- (returns) - A promise that resolves to an array of Inlay objects
vscode.executeFoldingRangeProvider
- Execute folding range provider
- uri - Uri of a text document
- (returns) - A promise that resolves to an array of FoldingRange objects
vscode.resolveNotebookContentProviders
- Resolve Notebook Content Providers
- (returns) - A promise that resolves to an array of NotebookContentProvider static info objects.
vscode.executeInlineValueProvider
- Execute inline value provider
- uri - Uri of a text document
- range - A range in a text document
- context - An InlineValueContext
- (returns) - A promise that resolves to an array of InlineValue objects
vscode.open
- Opens the provided resource in the editor.
- Uri -
vscode.openWith
- Opens the provided resource with a specific editor.
- resource - Resource to open
- viewId - Custom editor view id or 'default' to use VS Code's default editor
- columnOrOptions - (optional) Either the column in which to open or editor options, see vscode.TextDocumentShowOptions
- (returns) - no result
vscode.diff
- Opens the provided resources in the diff editor to compare their contents.
- left - Left-hand side resource of the diff editor
- right - Right-hand side resource of the diff editor
- title - Human readable title for the diff editor
- options - (optional) Either the column in which to open, or editor options (see vscode.TextDocumentShowOptions)
vscode.changes
- Opens a list of resources in the changes editor to compare their contents.
- title - Human readable title for the changes editor
- resourceList - List of resources to compare
vscode.prepareTypeHierarchy
- Prepare type hierarchy at a position inside a document
- uri - Uri of a text document
- position - A position in a text document
- (returns) - A promise that resolves to an array of TypeHierarchyItem-instances
vscode.provideSupertypes
- Compute supertypes for an item
- item - A type hierarchy item
- (returns) - A promise that resolves to an array of TypeHierarchyItem-instances
vscode.provideSubtypes
- Compute subtypes for an item
- item - A type hierarchy item
- (returns) - A promise that resolves to an array of TypeHierarchyItem-instances
vscode.revealTestInExplorer
- Reveals a test instance in the explorer
- testItem - A VS Code TestItem.
- (returns) - no result
setContext
- Set a custom context key value that can be used in when clauses.
- name - The context key name
- value - The context key value
- (returns) - no result
vscode.executeMappedEditsProvider
- Execute Mapped Edits Provider
- uri - Uri of a text document
- string_array - Array of string,
- MappedEditsContext - Mapped Edits Context
- (returns) - A promise that resolves to a workspace edit or null
cursorMove
- Move cursor to a logical position in the view
- Cursor move argument object - Property-value pairs that can be passed through this argument:
- 'to': A mandatory logical position value providing where to move the cursor.
'left', 'right', 'up', 'down', 'prevBlankLine', 'nextBlankLine', 'wrappedLineStart', 'wrappedLineEnd', 'wrappedLineColumnCenter' 'wrappedLineFirstNonWhitespaceCharacter', 'wrappedLineLastNonWhitespaceCharacter' 'viewPortTop', 'viewPortCenter', 'viewPortBottom', 'viewPortIfOutside'
- 'by': Unit to move. Default is computed based on 'to' value.
'line', 'wrappedLine', 'character', 'halfLine'
- 'value': Number of units to move. Default is '1'.
- 'select': If 'true' makes the selection. Default is 'false'.
- 'to': A mandatory logical position value providing where to move the cursor.
editorScroll
- Scroll editor in the given direction
- Editor scroll argument object - Property-value pairs that can be passed through this argument:
- 'to': A mandatory direction value.
'up', 'down'
- 'by': Unit to move. Default is computed based on 'to' value.
'line', 'wrappedLine', 'page', 'halfPage', 'editor'
- 'value': Number of units to move. Default is '1'.
- 'revealCursor': If 'true' reveals the cursor if it is outside view port.
- 'to': A mandatory direction value.
revealLine
- Reveal the given line at the given logical position
- Reveal line argument object - Property-value pairs that can be passed through this argument:
- 'lineNumber': A mandatory line number value.
- 'at': Logical position at which line has to be revealed.
'top', 'center', 'bottom'
editor.unfold
- Unfold the content in the editor
- Unfold editor argument - Property-value pairs that can be passed through this argument:
- 'levels': Number of levels to unfold. If not set, defaults to 1.
- 'direction': If 'up', unfold given number of levels up otherwise unfolds down.
- 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the unfold action to. If not set, the active selection(s) will be used.
editor.fold
- Fold the content in the editor
- Fold editor argument - Property-value pairs that can be passed through this argument:
- 'levels': Number of levels to fold.
- 'direction': If 'up', folds given number of levels up otherwise folds down.
- 'selectionLines': Array of the start lines (0-based) of the editor selections to apply the fold action to. If not set, the active selection(s) will be used. If no levels or direction is set, folds the region at the locations or if already collapsed, the first uncollapsed parent instead.
editor.toggleFold
- Folds or unfolds the content in the editor depending on its current state
editor.actions.findWithArgs
- Open a new In-Editor Find Widget with specific options.
- searchString - String to prefill the find input
- replaceString - String to prefill the replace input
- isRegex - enable regex
- preserveCase - try to keep the same case when replacing
- findInSelection - restrict the find location to the current selection
- matchWholeWord
- isCaseSensitive
editor.action.goToLocations
- Go to locations from a position in a file
- uri - The text document in which to start
- position - The position at which to start
- locations - An array of locations.
- multiple - Define what to do when having multiple results, either
peek
,gotoAndPeek
, or `goto - noResultsMessage - Human readable message that shows when locations is empty.
editor.action.peekLocations
- Peek locations from a position in a file
- uri - The text document in which to start
- position - The position at which to start
- locations - An array of locations.
- multiple - Define what to do when having multiple results, either
peek
,gotoAndPeek
, or `goto
workbench.action.quickOpen
- Quick access
- prefix -
notebook.cell.toggleOutputs
- Toggle Outputs
- options - The cell range options
notebook.fold
- Fold Cell
- index - The cell index
notebook.unfold
- Unfold Cell
- index - The cell index
notebook.selectKernel
- Notebook Kernel Args
- kernelInfo - The kernel info
notebook.cell.changeLanguage
- Change Cell Language
- range - The cell range
- language - The target cell language
notebook.execute
- Run All
- uri - The document uri
notebook.cell.execute
- Execute Cell
- options - The cell range options
notebook.cell.executeAndFocusContainer
- Execute Cell and Focus Container
- options - The cell range options
notebook.cell.cancelExecution
- Stop Cell Execution
- options - The cell range options
workbench.action.findInFiles
- Open a workspace search
- A set of options for the search -
_interactive.open
- Open Interactive Window
- showOptions - Show Options
- resource - Interactive resource Uri
- controllerId - Notebook controller Id
- title - Notebook editor title
interactive.execute
- Execute the Contents of the Input Box
- resource - Interactive resource Uri
search.action.openNewEditor
- Open a new search editor. Arguments passed can include variables like ${relativeFileDirname}.
- Open new Search Editor args -
search.action.openEditor
- Open a new search editor. Arguments passed can include variables like ${relativeFileDirname}.
- Open new Search Editor args -
search.action.openNewEditorToSide
- Open a new search editor. Arguments passed can include variables like ${relativeFileDirname}.
- Open new Search Editor args -
vscode.openFolder
- Open a folder or workspace in the current window or new window depending on the newWindow argument. Note that opening in the same window will shutdown the current extension host process and start a new one on the given folder/workspace unless the newWindow parameter is set to true.
- uri - (optional) Uri of the folder or workspace file to open. If not provided, a native dialog will ask the user for the folder
- options - (optional) Options. Object with the following properties:
forceNewWindow
: Whether to open the folder/workspace in a new window or the same. Defaults to opening in the same window.forceReuseWindow
: Whether to force opening the folder/workspace in the same window. Defaults to false.noRecentEntry
: Whether the opened URI will appear in the 'Open Recent' list. Defaults to false. Note, for backward compatibility, options can also be of type boolean, representing theforceNewWindow
setting.
vscode.newWindow
- Opens an new window depending on the newWindow argument.
- options - (optional) Options. Object with the following properties:
reuseWindow
: Whether to open a new window or the same. Defaults to opening in a new window.
vscode.removeFromRecentlyOpened
- Removes an entry with the given path from the recently opened list.
- path - URI or URI string to remove from recently opened.
moveActiveEditor
- Move the active editor by tabs or groups
- Active editor move argument - Argument Properties:
- 'to': String value providing where to move.
- 'by': String value providing the unit for move (by tab or by group).
- 'value': Number value providing how many positions or an absolute position to move.
copyActiveEditor
- Copy the active editor by groups
- Active editor copy argument - Argument Properties:
- 'to': String value providing where to copy.
- 'value': Number value providing how many positions or an absolute position to copy.
vscode.getEditorLayout
- Get Editor Layout
- (returns) - An editor layout object, in the same format as vscode.setEditorLayout
workbench.action.files.newUntitledFile
- New Untitled Text File
- New Untitled Text File arguments - The editor view type or language ID if known
workbench.extensions.installExtension
- Install the given extension
- extensionIdOrVSIXUri - Extension id or VSIX resource uri
- options - (optional) Options for installing the extension. Object with the following properties:
installOnlyNewlyAddedFromExtensionPackVSIX
: When enabled, VS Code installs only newly added extensions from the extension pack VSIX. This option is considered only when installing VSIX.
workbench.extensions.uninstallExtension
- Uninstall the given extension
- Id of the extension to uninstall -
workbench.extensions.search
- Search for a specific extension
- Query to use in search -
workbench.action.tasks.runTask
- Run Task
- args - Filters the tasks shown in the Quick Pick
workbench.action.openIssueReporter
- Open the issue reporter and optionally prefill part of the form.
- options - Data to use to prefill the issue reporter with.
vscode.openIssueReporter
- Open the issue reporter and optionally prefill part of the form.
- options - Data to use to prefill the issue reporter with.
workbench.action.openLogFile
- workbench.action.openLogFile
- logFile -
workbench.action.openWalkthrough
- Open the walkthrough.
- walkthroughID - ID of the walkthrough to open.
- toSide - Opens the walkthrough in a new editor group to the side.
Simple commands
Simple commands that do not require parameters can be found in the Keyboard Shortcuts list in the default keybindings.json
file. The unbound commands are listed in a comment block at the bottom of the file.
To review the default keybindings.json
, run Preferences: Open Default Keyboard Shortcuts (JSON) from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)).