How to Open a New File in a Separate Workspace in Visual Studio Code

Abstract: Isolate a file in Visual Studio Code by creating a dedicated folder and saving it as a new workspace to ensure independent settings.

Created: 2026-08-16 by
To open a new file in a separate Visual Studio Code workspace, you must first create a dedicated folder for that project and then add it to your current instance or open it as a new window. By default, VS Code treats multiple files within the same root directory as part of a single workspace. To isolate a file or group of files into its own distinct environment with independent settings and extensions, you need to explicitly define a workspace root. This process ensures that configurations do not bleed into other projects, providing a clean slate for focused development tasks without cluttering your primary workspace view.

Understanding Workspaces vs. Folders

Visual Studio Code distinguishes between opening a folder and opening a workspace. When you open a folder, VS Code loads all files within that directory tree into the Explorer sidebar. If you simply open a single file from outside any folder, it appears in the editor but does not constitute a "workspace" in the traditional sense because there is no root directory defined. A workspace is essentially a saved configuration that points to one or more folders. To achieve separation, you must ensure the target file resides in its own unique folder structure.

This distinction is crucial because many VS Code features, such as task definitions, launch configurations, and specific extension scopes, rely on the presence of a .vscode folder at the root of the workspace. Without this root, those configurations cannot be properly scoped to that specific set of files.

Creating a Separate Workspace via Command Palette

The most direct method to create a new workspace involves using the Command Palette. This approach allows you to save the current state of your editor, including open tabs and window layout, into a new workspace file. Follow these steps to isolate your work:

  • Open the Command Palette: Press Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on macOS.
  • Select Save As Workspace: Type "Save Workspace As" in the search bar and select the command. Alternatively, if you have files open, you can choose "Save Current As New Workspace."
  • Choose a Location: Navigate to a new directory where you want to store this workspace configuration. It is best practice to keep the workspace file (.code-workspace) inside the project folder itself or in a parent directory dedicated to workspace definitions.
  • Name the File: Give it a descriptive name, such as my-project.code-workspace, and click Save.

Once saved, VS Code will reload using this new workspace definition. Any subsequent files opened while this workspace is active will be associated with it, provided they are within the defined root folders. This creates a clear boundary between this project and any previously open workspaces.

Opening a Folder as a New Window

Another common workflow involves keeping multiple projects visible simultaneously by launching them in separate VS Code windows. This is useful when you need to reference code from Project A while working on Project B. To do this, navigate to the folder containing your new file in your operating system's file explorer. Right-click the folder and select "Open with Code." Alternatively, inside an existing VS Code window, go to File > New Window. Then, use File > Open Folder to load the specific directory containing your new file. Each window operates independently, meaning you can have different terminal sessions, debuggers, and extension states active in each.

This method is particularly effective for managing context switching. You can arrange these windows side-by-side on your monitor. For users who prefer keyboard shortcuts, binding a custom keybinding to "New Window" can significantly speed up this workflow. However, be aware that having too many windows open can consume significant memory resources, so balance this with your system capabilities.

Configuring Window Restore Behavior

A frequent point of confusion arises when users expect their separate workspaces to open automatically upon restarting VS Code. The setting that controls this behavior is window.restoreWindows, not window.startupBehavior. This setting determines how VS Code handles windows and workspaces when the application launches. You can find this setting in File > Preferences > Settings (or Code > Preferences > Settings on macOS).

The available options for window.restoreWindows include:

  • none: Opens a blank window without restoring previous sessions.
  • restore: Restores the last closed windows and their respective workspaces.
  • all: Restores all previously opened windows, even if they were not explicitly closed.
  • folders: Restores only the folders that were open, ignoring the window layout.

Setting this to restore or all ensures that your isolated workspace opens exactly as you left it, maintaining the separation you established. Incorrectly configuring this can lead to all your projects merging into a single window, defeating the purpose of creating separate environments.

Managing Workspace Settings

Once your separate workspace is established, you can customize settings specifically for that context. Open the Command Palette and type "Preferences: Open Workspace Settings". This opens a JSON interface where you can override global settings. For example, you might want a specific linter enabled only for this project, or a different font size. These settings are stored in the .vscode/settings.json file within the workspace root. Changes here do not affect your global user settings or other workspaces, ensuring that your isolated environment remains truly separate.

If you need to share these configurations with a team, commit the .vscode folder to your version control system. This allows collaborators to open the same workspace and inherit the specific tooling configurations. Conversely, if you wish to remove a workspace, simply delete the .code-workspace file and reopen the folder directly, which reverts VS Code to treating it as a standard folder rather than a named workspace entity.

Frequently Asked Questions

How do I close a specific workspace without closing VS Code?

To close a workspace, go to File > Close Workspace. This action closes the current workspace but keeps the VS Code application running, allowing you to immediately open another folder or workspace. If you want to exit the application entirely, use File > Exit.

Can I merge two separate workspaces into one?

Yes, you can add multiple folders to a single workspace. Go to File > Add Folder to Workspace... and select the second folder. Both folders will appear in the Explorer sidebar under the same workspace root, sharing the same settings and terminal instances unless configured otherwise.

Why are my settings not applying to my new workspace?

Ensure that you are editing the Workspace settings, not the User settings. In the Settings UI, look for the toggle switch that says "Workspace" or check the JSON tab for "settings": {} inside the workspace scope. Global user settings apply everywhere, while workspace settings only apply to the current root folders.

What happens if I delete the .code-workspace file?

Deleting the .code-workspace file removes the saved workspace configuration. VS Code will revert to treating the root folder as a simple directory. Any custom tasks, launch configurations, or specific settings saved exclusively in that workspace file will be lost unless they are also present in the .vscode folder of the project.

Is there a limit to how many workspaces I can have open?

There is no hard limit imposed by VS Code itself, but performance may degrade if you have dozens of large workspaces open simultaneously across multiple windows. It is recommended to close unused workspaces regularly to free up memory and CPU resources, especially when running heavy language servers or debuggers.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More