VS Code CLI and URL Schemes

A quick reference for the most useful Visual Studio Code command-line interface (CLI) options and URL schemes.

Posted in til · Tagged with cli · url-schemes · vs-code
Updated August 9, 2025 · 2 minute read
vs-code-cli-and-url-schemes

Visual Studio Code has a powerful command-line interface (CLI) that lets you control how you launch the editor through command-line options (switches).

Opening Files and Folders

  • Open a file: code <file_path>. You can list multiple files separated by spaces. If a file doesn’t exist, it will be created. When opening multiple files, VS Code opens them all as tabs in a single window instance.
  • Open a folder: code <folder_path>. You can specify multiple folders separated by spaces to create a Multi-root Workspace that includes each folder and allows you to manage multiple project “roots” simultaneously.

Common CLI Options

Go to File Location 1

Open a file at a specific line and optional column.

Terminal window
code -g, --goto path/to/file:line[:column]

New Window

Open a fresh session of VS Code instead of restoring the previous session.

Terminal window
code -n, --new-window [path/to/folder-or-file]

You can also use -r or --reuse-window to force opening a file or folder in the last active window.

Wait for Close

Wait for the opened file to be closed before returning to the command line. This is useful for things like editing a Git commit message.

Terminal window
code -w, --wait path/to/file

Use a Specific Profile

Specify the directory for user data, which is useful for managing separate profiles or running as a different user.

Terminal window
code --user-data-dir "/path/to/custom/profile"

Disable Extensions

Open VS Code with all installed extensions temporarily disabled.

Terminal window
code --disable-extensions

Verbose Logging

Enables verbose logging, which is helpful for diagnosing issues.

Terminal window
code --verbose

Show Help

Displays all available CLI options.

Terminal window
code --help

Alternatively, you can view the manual page:

Terminal window
man code

Further Reading

For a complete list of options, see the official documentation:

URL Schemes

You can also use vscode:// URL schemes to open folders and files.

Open a Folder

vscode://file/{full path to folder}/

Open a File

vscode://file/{full path to file}

Open a File to a Specific Line and Column

vscode://file/{full path to file}:line:column

Footnotes

  1. The column number for character position is optional.

Thanks for reading! If you found this page useful, you can support my work by buying me a coffee.
© 2025 Hua-Ming Huang • licensed under CC BY 4.0