Open a Folder in VS Code from the Terminal (code .)

Launch Visual Studio Code on the current directory using its built-in command-line interface.

WindowsvscodedeveloperLow risk
In any terminal, cd into your project and run code . to open the folder as a VS Code workspace.

01Command

Command
$ code .

02What it does

The code command ships with VS Code: code . opens the current folder, code file.txt opens a single file, and code -r . reuses the last window instead of a new one. If the command is not found, Windows users should relaunch the terminal after ticking "Add to PATH" in the installer, or run the installer's repair option. This also works inside the VS Code integrated terminal for opening sibling folders quickly.

03Risk

RiskLow risk
RequirementsVisual Studio Code installed with the 'code' command on PATH — enable "Add to PATH" during setup, or run "Shell Command: Install 'code' command in PATH"
!Warning: The command does nothing useful if the terminal was opened before VS Code was installed — restart the terminal so PATH updates load.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Command Line Interface (VS Code)
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Documents the code CLI: code . opens the current folder, code file.txt opens files, and flags like -r/-n/-d control window reuse.

Last verified: 2026-09-18 · Category: Developer

06Related solutions