My Profile Image
written by Hua-Ming Huang
July 20, 2025 2 minutes read

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

vs-code-cli-and-url-schemes

Today I learned that 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.

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

New Window

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

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.

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.

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

Disable Extensions

Open VS Code with all installed extensions temporarily disabled.

code --disable-extensions

Verbose Logging

Enables verbose logging, which is helpful for diagnosing issues.

code --verbose

Show Help

Displays all available CLI options.

code --help

Alternatively, you can view the manual page:

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.

Email Me
Thanks for reading! If you found this page useful, consider buying me a coffee
© 2026 Hua-Ming Huang · licensed under CC BY 4.0