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...]
PARAMETERS
-n, --new-window
Open in a new window
-d, --diff
Compare two folders or files
-a, --add
Add folder(s) to the last active window
-g, --goto
Open file at path on line:col
-w, --wait
Wait for file to be closed before returning
-r, --reuse-window
Open in existing window
--help
Print usage
--version
Print version
--install-extension
Install extension
--list-extensions
List installed extensions
--uninstall-extension
Uninstall extension
-f, --folder-uri
Open folder from URI
-u, --user-data-dir
Specify user data directory
DESCRIPTION
The code command launches Visual Studio Code (VS Code), a popular open-source code editor developed by Microsoft. It allows users to open files, folders, or workspaces directly from the terminal, making it efficient for developers. When invoked without arguments, it opens VS Code in the current directory.
Key features include support for extensions, integrated terminal, Git integration, and debugging. The command integrates seamlessly with shell environments, enabling quick edits via commands like code file.txt. It supports multiple instances, new windows, and specific line navigation.
Installation typically adds code to PATH via VS Code's "Install 'code' command in PATH" option in the Command Palette (Ctrl+Shift+P). On Linux, it may require manual symlink setup from $VSCODE_PATH/bin/code. Ideal for scripting and automation, it enhances productivity in CLI-heavy workflows.
CAVEATS
Requires VS Code installed with 'code' in PATH; may not work in restricted environments without proper setup. Large workspaces can consume significant memory.
REMOTE USAGE
Supports code --remote ssh-remote+host for remote development after VS Code Server setup.
WORKSPACE SUPPORT
Use code --workspace workspace.code-workspace to open multi-root workspaces.
HISTORY
Introduced with Visual Studio Code 1.0 in 2015 by Microsoft. Evolved with VS Code releases, adding extension management and remote support in later versions (e.g., 1.30+ for CLI improvements). Widely adopted in Linux distros via snaps/flathub.


