VS Code Workspaces solve this by grouping multiple distinct folders into a unified environment with shared tasks, isolated extensions, and dedicated settings.
Single Folder vs. Multi-Root Workspaces
- Single Folder: The default mode. Settings live in
.vscode/settings.jsonwithin that folder. Good for standalone apps. - Multi-Root Workspace: A virtual wrapper managed by a
.code-workspacefile. It binds multiple distinct directories into one File Explorer sidebar, allowing root-level Git tracking, unified search, and folder-specific overrides.
Setting Up Your First Multi-Root Workspace
-
Open Your Initial Project Directory: Launch VS Code and open your primary root folder via File > Open Folder… (e.g.,
api-backend). -
Add Additional Folders to the Workspace: Navigate to File > Add Folder to Workspace… and select your secondary directories (such as
web-frontendorshared-types). They will now appear side-by-side in your File Explorer. -
Save the Workspace Configuration File: Go to File > Save Workspace As… and save the file (e.g.,
project.code-workspace) in your project root.
Inside the .code-workspace File
Under the hood, your workspace file is simple JSON. It controls three essential pillars: folders, global/folder settings, and extension recommendations.
{
"folders": [
{
"name": "Backend Service",
"path": "services/backend"
},
{
"name": "Web Client",
"path": "apps/frontend"
}
],
"settings": {
"editor.tabSize": 2,
"files.exclude": {
"**/.git": true,
"**/node_modules": true
},
"[python]": {
"editor.formatOnSave": true
}
},
"extensions": {
"recommendations": [
"esbenp.prettier-vscode",
"ms-python.python",
"dbaeumer.vscode-eslint"
]
}
}
How Workspaces Improve Development
1. Unified Search and Git Tracking
Search across every repository in your workspace with Ctrl+Shift+F (or Cmd+Shift+F). The Source Control panel automatically segments changes per repository, letting you stage and commit backend and frontend updates in parallel without switching windows.
2. Scope-Specific Tooling & Linters
Prevent configuration bleed. You can set Python/Ruff settings specifically for your backend while enforcing ESLint and Prettier strictly inside your frontend directory:
{
"settings": {
"services/backend": {
"python.defaultInterpreterPath": "./venv/bin/python"
}
}
}
3. Onboarding in Seconds via Recommended Extensions
Add required linters, formatters, and Docker tools directly to the "extensions.recommendations" block. When a teammate opens project.code-workspace, VS Code prompts them with a one-click install for the entire toolchain.
4. Cross-Project Task Automation
Define composite tasks in .vscode/tasks.json that start your entire stack—spinning up a Node server and a Python worker concurrently with a single shortcut (Ctrl+Shift+B / Cmd+Shift+B).
Best Practices
- Commit or Gitignore? If folder paths are relative (e.g.,
"path": "frontend"), commitproject.code-workspaceto version control so the team shares identical setup. If you’re aggregating unrelated personal repos, keep it local. - Keep Folders Lean: Exclude large build output directories (like
dist/,.next/, ortarget/) in the"files.watcherExclude"setting to maintain snappy search and low CPU usage. - Use Friendly Aliases: Add the
"name"property to your folder entries so folders appear in the sidebar as Web Client instead of generic names likeapp.