code
Open Visual Studio Code editor
TLDR
Start Visual Studio Code
Open specific files/directories
Compare two specific files
Open specific files/directories in a new window
Install/uninstall a specific extension
Display diagnostic and process information about the running code window
Print installed extensions with their versions
Start the editor as a superuser (root) while storing user data in a specific directory
SYNOPSIS
code [options] [paths...]
code [command] [args...]
PARAMETERS
-d, --diff The code command is the command-line interface (CLI) for Visual Studio Code, a popular cross-platform source-code editor developed by Microsoft. It allows users to effortlessly open files, directories, or even remote workspaces directly from their terminal. This utility is instrumental in integrating VS Code into various development workflows, enabling quick file access, scripting, and version control operations. Whether you need to open a specific file for editing, start a new project in the current directory, or compare two files side-by-side, the code command provides a direct and efficient pathway to your editor. It's designed for seamless interaction, supporting numerous options to control how VS Code launches, such as opening in a new window, reusing an existing one, or waiting for files to be closed before returning control to the terminal. The code command requires Visual Studio Code to be installed on your system. On most operating systems, the command is added to your system's PATH during VS Code installation or via an explicit option within the editor (e.g., 'Shell Command: Install 'code' command in PATH' on macOS/Linux). Its functionality is entirely dependent on the installed VS Code application and its configuration. While Visual Studio Code is installed like any other application, the code command typically requires an additional step to be accessible directly from the terminal. On macOS and Linux, VS Code prompts users to install the 'code' command into their system's PATH via the 'Shell Command: Install 'code' command in PATH' option available in the Command Palette (Ctrl+Shift+P or Cmd+Shift+P). This creates a symbolic link that makes the executable globally available. The code command plays a pivotal role in VS Code's Remote Development capabilities. With extensions like 'Remote - SSH', 'WSL', or 'Dev Containers', users can open remote folders or repositories directly using the code command. For example, code --remote ssh-remote+ The code command emerged with the initial public release of Visual Studio Code by Microsoft in April 2015. From its inception, the CLI was a core component, designed to offer a familiar and efficient way for developers to interact with the editor directly from their terminal, mirroring capabilities found in other popular editors like Sublime Text and Atom. Its evolution closely mirrors the development of VS Code itself, continuously gaining new features and options to support advancements like integrated terminal features, remote development capabilities, and profile management, solidifying its role as an indispensable tool in modern software development workflows.
Compare two files side-by-side in VS Code's diff editor.
-h, --help
Display usage information and exit.
-n, --new-window
Force opening a new VS Code window.
-r, --reuse-window
Force opening in the last active VS Code window (this is the default behavior).
-w, --wait
Wait for the files to be closed in VS Code before returning control to the terminal.
--add
Add folder(s) to the last active VS Code window.
--goto
Open a file at the specified line and character position.
--install-extension
Install a VS Code extension by its unique ID.
--list-extensions
List all installed VS Code extensions.
--profile
Open VS Code with the specified profile.
--remote :
Open a path in a remote context (e.g., SSH, Dev Containers).
--version
Print the VS Code version to the console.
DESCRIPTION
CAVEATS
INSTALLATION AND PATH INTEGRATION
On Windows, the installer usually offers an option to 'Add 'Open with Code' action to Windows Explorer file/directory context menu' and adds VS Code to the system PATH environment variable, making the code command available in PowerShell or Command Prompt automatically.REMOTE DEVELOPMENT INTEGRATION
HISTORY
SEE ALSO