Documentation
Topics Overview Overview Agents Quickstart Editor Tutorial Intro Videos Overview Get started Agents Quickstart Agents Tutorial Best Practices Concepts Agents Agent Harnesses Language Models Context Tools Sessions & Handoff Agent Host Architecture Customization Workspace Context Trust & Safety Run agents Chat View Agents Window Automations Choose an Agent Harness Approvals & Permissions AI Security Review & Revert Changes Use Tools Browser Tools Plan Work Artifacts Remote Agent Sessions Memory Subagents Sessions Manage Sessions Session History Configure the Agents Window Customize agents Create and Manage Instructions Agent Skills Custom Agents Language Models MCP Hooks Plugins Prompt Files Tutorials & guides Configure AI for your project Fix an API Bug Delegate Two Tasks Without Mixing Their Changes Test Code with AI Test Web Apps with Browser Tools Get an Agent Back on Track Context Engineering Test-Driven Development Work with Jupyter Notebooks using AI Optimize AI Credit Usage MCP Dev Guide Prompt Examples Reference Cheat Sheet Settings Reference VS Code Pet MCP Configuration Hooks Reference OpenTelemetry Monitoring Troubleshooting Troubleshooting Debug Chat Interactions Diagnose Prompt Caching FAQ Chat Interactions Inline & Quick Chat Add Prompt Context Overview Getting Started Editor Tutorial User Interface Tips and Tricks Write code Basic Editing IntelliSense Inline Suggestions Smart Actions Code Navigation Refactoring Snippets Workspaces Overview Multi-Root Workspaces Workspace Trust Configure the editor Display Language Layout Keyboard Shortcuts Settings Settings Sync Extensions Overview Extension Marketplace Extension Runtime Security Themes Profiles Accessibility Overview Voice Interactions Command Line Interface Telemetry Reference Default Keyboard Shortcuts Default Settings Substitution Variables Tasks Schema Overview Quickstart Repositories & Remotes Staging & Committing Source Control History Branches & Worktrees Merge Conflicts Collaborate on GitHub Troubleshooting FAQ Get Started Terminal Basics Terminal Profiles Shell Integration Appearance Advanced Debugging Debug Configuration Tasks Testing Integrated Browser Port Forwarding Guides & Tutorials Test-Driven Development Test Web Apps with Browser Tools Overview Enterprise Policies AI Settings Extensions Telemetry Updates Overview VS Code for the Web SSH SSH Tutorial Tunnels Dev Containers WSL WSL Tutorial GitHub Codespaces VS Code Server Linux Prerequisites Tips and Tricks FAQ GitHub Copilot Setup Linux macOS Windows Raspberry Pi Network Portable Mode Additional Components Uninstall Languages & Runtimes Extension DocsOn this page there are 13 sections
Command Line Interface (CLI)
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 .:
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.
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 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 toagent.-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:
# First instance with its own environment
code ~/project1 --user-data-dir ~/vscode-data-project1
# Second instance with different environment
code ~/project2 --user-data-dir ~/vscode-data-project2
Each instance with a different --user-data-dir will maintain its own:
- Environment variables
- Settings and preferences
- Installed extensions
- UI state and layout
When using --user-data-dir, you'll need to reinstall extensions for each user data directory, as extensions are stored separately.
Create remote tunnel
VS Code integrates with other remote environments to become even more powerful and flexible. Our goal is to provide a cohesive experience that allows you to manage both local and remote machines from one, unified CLI.
The Visual Studio Code Remote - Tunnels extension lets you connect to a remote machine, like a desktop PC or VM, via a secure tunnel. Tunneling securely transmits data from one network to another. You can then securely connect to that machine from anywhere, without the requirement of SSH.
We've built functionality into the code CLI that will initiate tunnels on remote machines. You can run:
vscode://file/{full path to project}/
vscode://file/c:/myProject/
Open a file
vscode://file/{full path to file}:line:column
vscode://file/c:/myProject/package.json:5:10
Open the Settings Editor
| Web Proxy Viewer | New URL | Original Page |