Command Line Interface (CLI)
AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. 🎬 Watch The Story of VS Code! VS Code is now on Instagram, follow @vscode.ig for updates, tips, and more. Rewatch GitHub Copilot Day. Command Line Interface (CLI) View as Markdown Ask in VS Code Ask in VS Code Insiders Visual Studio Code has a powerful command-line interface built-in that lets you control how you launch the editor.
You can open files, install extensions, change the display language, and output diagnostics through command-line options (switches). If you are looking for how to run command-line tools inside VS Code, see the Integrated Terminal . Command line help To get an overview of the VS Code command-line interface, open a terminal or command prompt and type code --help . You will see the version, usage example, and list of command line options.
Launching from command line You can launch VS Code from the command line to quickly open a file, folder, or project. Typically, you open VS Code within the context of a folder. To do this, from an open terminal or command prompt, navigate to your project folder and type code . : Note Users on macOS must first run a command ( Shell Command: Install 'code' command in PATH ) to add VS Code executable to the PATH environment variable.
Read the macOS setup guide for help. Windows and Linux installations should add the VS Code binaries location to your system path. If this isn't the case, you can manually add the location to the Path environment variable ( $PATH on Linux). For example, on Windows, the default VS Code binaries location is AppData\Local\Programs\Microsoft VS Code\bin . To review platform-specific setup instructions, see Setup . Note If you are using the VS Code Insiders preview, you launch your Insiders build with code-insiders .
Core CLI options Here are optional arguments you can use when starting VS Code at the command line via code : Argument Description -h or --help Print usage -v or --version Print VS Code version (for example, 1.22.2), GitHub commit ID, and architecture (for example, x64). -n or --new-window Opens a new session of VS Code instead of restoring the previous session (default). -r or --reuse-window Forces opening a file or folder in the last active window. - Read from stdin and open it in VS Code (for example, 'echo Hello World -g or --goto When used with file:line{:character} , opens a file at a specific line and optional character position.
This argument is provided since some operating systems permit : in a file name. -d or --diff <file1> <file2> Open a file difference editor. Requires two file paths as arguments. -m or --merge <path1> <path2> <base> <result> Perform a three-way merge by providing paths for two modified versions of a file, the common origin of both modified versions, and the output file to save merge results. -w or --wait Wait for the files to be closed before returning. --locale <locale> Set the display language (locale) for the VS Code session. (for example, en-US or zh-TW ) Opening Files and Folders Sometimes you will want to open or create a file.
If the specified file does not exist, VS Code will create them for you along with any new intermediate folders: code index.html style.css documentation \r eadme.md For both files and folders, you can use absolute or relative paths. Relative paths are relative to the current directory of the command prompt where you run code . If you specify more than one file at the command line, VS Code will open only a single instance.
If you specify more than one folder at the command line, VS Code will create a Multi-root Workspace including each folder. Argument Description file Name of a file to open. If the file doesn't exist, it will be created and marked as edited. You can specify multiple files by separating each file name with a space. file:line[:character] Used with the -g argument. Name of a file to open at the specified line and optional character position. folder Name of a folder to open.
You can specify multiple folders and a new Multi-root Workspace is created. --skip-add-to-recently-opened Prevent the opened files and folders from being added to the recently opened list. Select a profile You can launch VS Code with a specific profile via the --profile command-line interface option. You pass the name of the profile after the --profile argument and open a folder or a workspace using that profile. The command line below opens the web-sample folder with the "Web Development" profile: code ~/projects/web-sample --profile "Web Development" If the profile specified does not exist, a new empty profile with the given name is created.
Working with extensions You can install and manage VS Code extensions from the command line. Argument Description --install-extension <extension-id> | <extension-vsix-path> Install or update an extension. Provide either the full extension name publisher.extension or the path to a VSIX file as an argument. To install a specific version provide append @{version} . For example: vscode.csharp@1.2.3 . Use --force argument to avoid prompts.
Use --profile argument to install for a certain profile. --uninstall-extension <extension-id> Uninstall an extension. Provide the full extension name publisher.extension as an argument. Use --profile argument to uninstall for a certain profile. --disable-extensions Disable all installed extensions. Extensions will still be visible in the Disabled section of the Extensions view but they will never be activated. --list-extensions List the installed extensions. --profile argument can be used to list for a certain profile. --show-versions Show versions of installed extensions, when using --list-extensions --enable-proposed-api <ext> Enables proposed api features for an extension.
Provide the full extension name publisher.extension as an argument. --update-extensions Update installed extensions and exit. Start chat from the command line You can start a chat session directly from the command line by using the chat subcommand in the VS Code CLI. This enables you to open a chat session in your current working directory with a prompt you provide. For example, the following command opens chat for the current directory and asks "Find and fix all untyped variables": code chat Find and fix all untyped variables The chat subcommand has the following command-line options: -m , --mode <mode> : The custom agent to use for the chat session.
Available options: ask , edit , agent , or the identifier of a custom agent. Defaults to agent . -a , --add-file <path> : Add files as context to the chat session. --maximize : Maximize the chat session view. -r , --reuse-window : Use the last active window for the chat session. -n , --new-window : Open an empty window for the chat session. The chat subcommand also supports piping input from stdin by passing - at the end of the command.
For example: python app.py | code chat why does it fail - Advanced CLI options There are several CLI options that help with reproducing errors and advanced setup. Argument Description --extensions-dir <dir> Set the root path for extensions. Overridden in Portable Mode by the data folder. --user-data-dir <dir> Specifies the directory that user data is kept in. Can be used to run multiple isolated instances of VS Code with separate environments, settings, and extensions.
Also useful when running as root. Overridden in Portable Mode by the data folder. -s, --status Print process usage and diagnostics information. -p, --performance Start with the Developer: Startup Performance command enabled. --disable-gpu Disable GPU hardware acceleration. --verbose Print verbose output (implies --wait ). --prof-startup Run CPU profiler during startup. --upload-logs Uploads logs from current session to a secure endpoint. --remote <authority> Connect to a remote development environment.
The authority specifies the remote connection for WSL ( wsl+<distr
The rest of this page is on the live site.