Skip to main content

Commands Overview

The VS Code CLI provides several powerful commands for managing your development environment:
code [options] [paths...]     # Open files/folders
code tunnel                   # Create remote tunnel
code ext                      # Manage extensions
code status                   # Print diagnostics
code version                  # Manage VS Code versions
code serve-web                # Run local web server

Opening Files and Folders

The default command (no subcommand) opens files and folders in VS Code.

Basic Usage

# Open current directory
code .

# Open specific files
code file1.js file2.js

# Open from stdin
cat README.md | code -

Editor Options

--diff
file file
Compare two files with each other
code --diff old.js new.js
--add
folder
Add folder(s) to the last active window
code --add ~/projects/library
--goto
file:line[:character]
Open a file at the specified line and character position
code --goto index.ts:42:15
--new-window
boolean
default:"false"
Force opening a new window
code --new-window ~/project
--reuse-window
boolean
default:"false"
Force reusing an existing window
code --reuse-window file.txt
--wait
boolean
default:"false"
Wait for the files to be closed before returning. Essential for Git editor integration.
export EDITOR="code --wait"
git commit  # Opens commit message in VS Code and waits
--locale
string
Set the display language (locale)
code --locale=ja-JP
--enable-proposed-api
extension-id...
Enable proposed API features for specified extensions
code --enable-proposed-api publisher.extension-name

Extension Management

Manage VS Code extensions from the command line.

ext list

List all installed extensions:
code ext list
code ext list
ms-python.python
dbaeumer.vscode-eslint
esbenp.prettier-vscode

Options

--show-versions
boolean
Display version numbers alongside extension IDs
--category
string
Filter extensions by category (e.g., themes, formatters, linters)

ext install

Install one or more extensions:
code ext install <extension-id>
code ext install ms-python.python

Options

<id-or-path>
string[]
required
Extension identifier(s) in format ${publisher}.${name} or path(s) to VSIX file(s). Use @${version} to install specific version.
--pre-release
boolean
Install the pre-release version of the extension
--force
boolean
Update to the latest version even if already installed
--donot-include-pack-and-dependencies
boolean
Don’t install extension packs and dependencies

ext uninstall

Uninstall one or more extensions:
code ext uninstall <extension-id>
code ext uninstall ms-python.python
code ext uninstall ms-python.python dbaeumer.vscode-eslint
<extension-id>
string[]
required
One or more extension identifiers to uninstall

ext update

Update all installed extensions to their latest versions:
code ext update

Status Command

Print process usage and diagnostics information:
code status
This displays detailed information about running VS Code processes, memory usage, CPU usage, and other diagnostic data. Useful for troubleshooting performance issues.
code status

Version:          1.85.0
Commit:           a0d0e3f
Date:             2023-11-29T10:15:30.000Z
Electron:         25.9.7
Chrome:           114.0.5735.289
Node.js:          18.15.0
V8:               11.4.183.29
OS:               Linux x64 5.15.0

CPU Usage:
  Renderer:       8%
  Extension Host: 2%
  
Memory Usage:
  Renderer:       245 MB
  Extension Host: 87 MB

Version Management

Manage and switch between different VS Code versions.

version use

Switch to a different VS Code version:
code version use <version>
code version use stable

Options

<version>
string
required
Version to use: stable, insiders, specific version number (e.g., 1.85.0), or absolute path to existing installation
--install-dir
path
Directory where the version can be found

version show

Display the currently configured VS Code version:
code version show
code version show
Current quality: stable
Installation path: /usr/share/code

Web Server

Run a local web version of VS Code accessible via browser.
code serve-web [options]
code serve-web
# Web UI available at http://localhost:8000?tkn=<token>

Options

--host
string
default:"localhost"
Host to listen on
code serve-web --host 0.0.0.0
--port
number
default:"8000"
Port to listen on. Use 0 for random free port.
code serve-web --port 0  # Random port
--socket-path
string
Path to a socket file for the server to listen on
--connection-token
string
A secret that must be included with all requests for authentication
--connection-token-file
string
Path to file containing the connection token
--without-connection-token
boolean
Run without a connection token (only if connection is secured by other means)
Only use this option if you have other security measures in place, as it removes authentication.
--server-base-path
string
Specifies the path under which the web UI and code server are provided
code serve-web --server-base-path /vscode
# Access at http://localhost:8000/vscode
--server-data-dir
string
Directory where server data is kept
--commit-id
string
Use a specific commit SHA for the client
--accept-server-license-terms
boolean
Accept the server license terms without prompting

Troubleshooting Options

These options help diagnose and fix issues:
--disable-extensions
boolean
Disable all installed extensions
code --disable-extensions
--disable-extension
extension-id...
Disable specific extension(s)
code --disable-extension ms-python.python
--disable-gpu
boolean
Disable GPU hardware acceleration
code --disable-gpu
--prof-startup
boolean
Run CPU profiler during startup for performance analysis
--inspect-extensions
port
Allow debugging and profiling of extensions
code --inspect-extensions=9333
--inspect-brk-extensions
port
Like --inspect-extensions, but pauses extension host at start
--sync
on | off
Turn settings sync on or off
code --sync=off
--telemetry
boolean
Shows all telemetry events the editor collects

Configuration Options

--extensions-dir
directory
Set the root path for extensions
code --extensions-dir ~/.vscode-extensions-custom
--user-data-dir
directory
Specify directory for user data. Useful for running multiple isolated instances.
code --user-data-dir ~/.vscode-test
--use-version
string
Set the editor version for this command. Can be persisted with code version use.
code --use-version insiders .

Legacy Command Support

The CLI maintains backward compatibility with legacy flags:
code ext list --show-versions
code ext install ms-python.python
code ext uninstall ms-python.python
While legacy flags are supported for backward compatibility, using the modern command syntax (code ext ...) is recommended for new scripts.

Exit Codes

The CLI returns standard exit codes:
  • 0 - Success
  • 1 - General error or installation not found
  • Other non-zero values indicate specific errors
These can be used in scripts for error handling:
if code ext install ms-python.python; then
  echo "Extension installed successfully"
else
  echo "Failed to install extension"
  exit 1
fi

Next Steps

Remote Tunnels

Learn about the powerful tunnel command for remote development

CLI Overview

Return to CLI overview and introduction

Build docs developers (and LLMs) love