Basic Syntax
Opening Files and Folders
The default behavior (no subcommand) launches VS Code with the specified files or folders.Options
string[]
One or more files, folders, or URIs to open. Can also use
- to read from stdin.Examples
Editor Options
string[]
Compare two files with each other.
string
Add folder(s) to the last active window.
string
Open a file at the specified line and character position. Format:
file:line[:character]boolean
Force to open a new window.
boolean
Force to open a file or folder in an existing window.
boolean
Wait for the files to be closed before returning. Useful for using VS Code as an editor for git commit messages.
string
The locale to use (e.g., en-US or zh-TW).
string[]
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.
boolean
Show versions of installed extensions.
string
Filters installed extensions by provided category.
code ext install
Install one or more extensions.
string[]
required
Extension identifier(s) in the format
publisher.name or path(s) to VSIX file(s).boolean
Installs the pre-release version of the extension.
boolean
Update to the latest version of the extension if it’s already installed.
boolean
Don’t include installing pack and dependencies of the extension.
code ext uninstall
Uninstall one or more extensions.
string[]
required
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.
string
required
The version to use. Can be:
stable- Latest stable releaseinsiders- Latest insiders buildx.y.z- Specific version number- Absolute path to an existing install
string
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.
string
Sets the machine name for port forwarding service.
boolean
Randomly name machine for port forwarding service.
boolean
Accept the server license terms automatically without a user prompt.
boolean
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
string
default:"localhost"
Host to listen on.
number
default:"8000"
Port to listen on. If 0 is passed, a random free port is picked.
string
Path to a socket file for the server to listen to.
string
A secret that must be included with all requests.
string
A file containing a secret that must be included with all requests.
boolean
Run without a connection token. Only use if the connection is secured by other means.
string
Specifies the path under which the web UI and code server are provided.
string
Specifies the directory that server data is kept in.
string
Use a specific commit SHA for the client.
boolean
Accept the server license terms automatically.
Desktop Code Options
These options apply whenever the desktop editor is launched.string
Set the root path for extensions.
string
Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of the editor.
string
Sets the editor version to use for this command. Can be
stable, insiders, a version number, or an absolute path.Troubleshooting Options
boolean
Disable all installed extensions.
string[]
Disable specific extension(s).
boolean
Disable GPU hardware acceleration.
string
Turn sync on or off. Values:
on, offnumber
Allow debugging and profiling of extensions. Specify the debug port.
number
Allow debugging and profiling of extensions with the extension host being paused after start.
boolean
Run CPU profiler during startup.
boolean
Show all telemetry events which the editor collects.
Global Options
These options are available for all commands.boolean
Print verbose output.
string
Log level to use. Values:
off, critical, error, warn, info, debug, tracestring
Directory where CLI metadata should be stored.Can also set via environment variable:
VSCODE_CLI_DATA_DIRboolean
Disable telemetry for the current command.
string
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.
boolean
Only check for updates without actually updating.
Server Options
Options available for tunnel and serve-web commands that start a server.string[]
Requests that extensions be preloaded and installed on connecting servers.
string
Specifies the directory that server data is kept in.
string
Set the root path for extensions on the server.
number
default:"10800"
Reconnection grace time in seconds. Default is 10800 (3 hours).
Environment Variables
The CLI respects these environment variables:string
Override the CLI data directory.
string
Provide access token for tunnel authentication.
string
Provide refresh token for tunnel authentication.
string
Require token string for command shell connections.
string
Disable interactive prompts.
string
Disable colored output.
string
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