Basic Syntax
Opening Files and Folders
The default behavior (no subcommand) launches VS Code with the specified files or folders.Options
One or more files, folders, or URIs to open. Can also use
- to read from stdin.Examples
Editor Options
Compare two files with each other.
Add folder(s) to the last active window.
Open a file at the specified line and character position. Format:
file:line[:character]Force to open a new window.
Force to open a file or folder in an existing window.
Wait for the files to be closed before returning. Useful for using VS Code as an editor for git commit messages.
The locale to use (e.g., en-US or zh-TW).
Enables proposed API features for extensions. Can receive one or more extension IDs.
Extension Commands
Manage VS Code extensions from the command line.code ext list
List installed extensions.
Show versions of installed extensions.
Filters installed extensions by provided category.
code ext install
Install one or more extensions.
Extension identifier(s) in the format
publisher.name or path(s) to VSIX file(s).Installs the pre-release version of the extension.
Update to the latest version of the extension if it’s already installed.
Don’t include installing pack and dependencies of the extension.
code ext uninstall
Uninstall one or more extensions.
Extension identifier(s) to uninstall in the format
publisher.name.code ext update
Update all installed extensions to their latest versions.
Status Command
code status
Print process usage and diagnostics information.
Version Commands
Manage which version of VS Code the CLI uses.code version show
Show the currently configured editor version.
code version use
Switch the version of VS Code you’re using.
The version to use. Can be:
stable- Latest stable releaseinsiders- Latest insiders buildx.y.z- Specific version number- Absolute path to an existing install
The directory where the version can be found.
Tunnel Commands
Create and manage secure remote tunnels. See the Remote Tunnels page for detailed information.code tunnel
Create a tunnel that’s accessible on vscode.dev from anywhere.
Sets the machine name for port forwarding service.
Randomly name machine for port forwarding service.
Accept the server license terms automatically without a user prompt.
Prevents the machine from going to sleep while the tunnel is running.
Tunnel Subcommands
- status
- kill
- restart
- rename
- unregister
- prune
Get tunnel status information.Returns JSON output with tunnel and service status.
Tunnel User Commands
Manage authentication for tunnels.- login
- logout
- show
Tunnel Service Commands
Manage the tunnel as a system service (runs in background).- install
- uninstall
- log
Serve Web Command
Run a local web version of VS Code.code serve-web
Host to listen on.
Port to listen on. If 0 is passed, a random free port is picked.
Path to a socket file for the server to listen to.
A secret that must be included with all requests.
A file containing a secret that must be included with all requests.
Run without a connection token. Only use if the connection is secured by other means.
Specifies the path under which the web UI and code server are provided.
Specifies the directory that server data is kept in.
Use a specific commit SHA for the client.
Accept the server license terms automatically.
Desktop Code Options
These options apply whenever the desktop editor is launched.Set the root path for extensions.
Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of the editor.
Sets the editor version to use for this command. Can be
stable, insiders, a version number, or an absolute path.Troubleshooting Options
Disable all installed extensions.
Disable specific extension(s).
Disable GPU hardware acceleration.
Turn sync on or off. Values:
on, offAllow debugging and profiling of extensions. Specify the debug port.
Allow debugging and profiling of extensions with the extension host being paused after start.
Run CPU profiler during startup.
Show all telemetry events which the editor collects.
Global Options
These options are available for all commands.Print verbose output.
Log level to use. Values:
off, critical, error, warn, info, debug, traceDirectory where CLI metadata should be stored.Can also set via environment variable:
VSCODE_CLI_DATA_DIRDisable telemetry for the current command.
Sets the initial telemetry level. Values:
off, crash, error, allStandalone CLI Commands
These commands are only available in standalone CLI installations.code update
Update the CLI to the latest version.
Only check for updates without actually updating.
Server Options
Options available for tunnel and serve-web commands that start a server.Requests that extensions be preloaded and installed on connecting servers.
Specifies the directory that server data is kept in.
Set the root path for extensions on the server.
Reconnection grace time in seconds. Default is 10800 (3 hours).
Environment Variables
The CLI respects these environment variables:Override the CLI data directory.
Provide access token for tunnel authentication.
Provide refresh token for tunnel authentication.
Require token string for command shell connections.
Disable interactive prompts.
Disable colored output.
Custom user agent for tunnel service.
Exit Codes
The CLI uses standard exit codes:0- Success1- General error or operation failed- Other non-zero values indicate specific error conditions
Tips and Best Practices
Using VS Code as Git Editor
Using VS Code as Git Editor
Configure VS Code as your git commit message editor:The
--wait flag makes git wait for you to close the file before continuing.Opening Large Projects Efficiently
Opening Large Projects Efficiently
Use
--new-window to avoid interfering with existing workspaces:Working with Multiple Profiles
Working with Multiple Profiles
Use
--user-data-dir to maintain separate profiles:Batch Extension Management
Batch Extension Management
Install multiple extensions at once:Export and import extension lists:
Next Steps
Remote Tunnels
Learn about secure remote access
Configuration
Configure the CLI for your workflow
Installation
Install the CLI on your system
Overview
Back to CLI overview