VS Code: Remove Folder from Workspace open Multiple Folders

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
6 min

banner

# Table of Contents

  1. Close an opened Project Folder in VS Code
  2. Remove a Folder from a Workspace in VS Code
  3. Open multiple Projects/Folders in VS Code
  4. How to add a folder to your existing Workspace in VS Code
  5. Using Drag and Drop to open multiple Projects/Folders
  6. Saving your Workspace configuration

# Close an opened Project Folder in VS Code

If you need to close your currently opened project folder:

  1. Click on File in the top menu and then click Close Folder.
  2. Note that you might have to press Alt to show the top menu on Windows and Linux.

file close folder

Here is a short clip that demonstrates the process.

close opened project folder

There is also a keyboard shortcut that you can use to close the current project folder:

  • on Windows and Linux: press Ctrl + K then press F.
  • on macOS: press Cmd + K then press F.

You first press Ctrl + K, release the keys and then press F.

You can view the keyboard shortcut for your operating system in this section of the docs.

You can hover over the key combination value in the Key column to view the value for other operating systems.

If you need to open a folder:

  1. Click on File in the top menu and then click Open Folder.
  2. Note that you might have to press Alt to show the top menu on Windows and Linux.

open folder

There is also a keyboard shortcut for the Open Folder command:

  • on Windows and Linux: press Ctrl + K, release the keys and then press Ctrl + O.
  • on macOS: press Cmd + K, release the keys and then press Cmd + O.

# Remove a Folder from a Workspace in VS Code

The Close Folder command closes your currently opened project folder.

If you need to remove a folder from a workspace:

  1. Make sure you have added the folder to the workspace by clicking on File in the top menu and then Add Folder to Workspace....
Note that you might have to press Alt to show the top menu on Windows and Linux.

file add folder to workspace

  1. Right-click on the folder in Explorer and select Remove Folder from Workspace.

right click remove folder from workspace

Here is a short clip that demonstrates the process.

right click remove folder from workspace

You can also remove a folder from a workspace by using the Command Palette.

  1. Press:
  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type remove folder from workspace and select Workspaces: Remove Folder from Workspace....

workspaces remove folder from workspace

  1. You will get prompted about which folder you want to remove from the workspace.

which folder to remove from workspace

Note that there is no option to add a subdirectory to a workspace.

You have to first remove the folder from the workspace and then add the subdirectories after.

Here is a short clip that demonstrates the process.

remove folder from workspace command palette

# How to open multiple Projects/Folders in VS Code

If you need to open the new folders in a new Window:

  1. Click on File in the top menu.
Note that you might have to press Alt to show the top menu on Windows and Linux.
  1. Select New Window.

click file select new window

You can also use the keyboard shortcut:

  • on Windows and Linux, press Ctrl + Shift + N
  • on macOS, press Cmd + Shift + N

In the new Window, select File in the top menu and then click Open Folder.

select file open folder

Select the folder you want to add to the Window.

However, when you open the folder in a new window, you aren't able to search through all folders in the multiple Windows at once.

# How to add a folder to your existing Workspace in VS Code

If you need to open multiple folders in the existing VS Code Window:

  1. Click on File in the top menu.
Note that you might have to press Alt to show the top menu on Windows and Linux.
  1. Select Add Folder to Workspace....

open multiple folders in current window

  1. Select the folder you want to add to the workspace.

The folders will appear side by side in Explorer.

folders shown side by side

You can right-click on any of the folders in Explorer and select:

  • Add Folder to Workspace to add a folder to the workspace (at the root).
  • Remove Folder from Workspace to remove the selected folder from the workspace.

right click to add or remove to workspace

Each folder in your workspace may contain folder-specific settings in .vscode/settings.json.

If you need to open the settings for a specific folder:

  1. Right-click on the folder.
  2. Select Open Folder Settings.

open folder specific settings

The settings UI opens with the specified folder selected.

edit folder specific settings

Any configuration only applies to the currently selected folder and overrides any global configuration.

If the User tab is selected, then settings are applied globally (to all folders in the workspace).

user tab selected

# Using Drag and Drop to open multiple Projects/Folders

You can also use drag and drop to open multiple folders.

If you drag and drop one or more folders to the Explorer region of your editor, they get added to the workspace.

add folders to workspace drag and drop

# Saving your Workspace configuration

When you first create your workspace, it will be marked as UNTITLED (WORKSPACE).

untitled workspace

If you want to save your workspace configuration and your workspace a name, you have to save it.

Otherwise, the workspace won't persist once you close the VS Code instance.

If you attempt to close an untitled workspace, you will get prompted whether you want to save it.

If you plan to open your workspace again, you should save it.

prompt whether to save workspace

Make sure to stick with the default location of where the workspace is saved.

You can also save your workspace by using the top menu.

  1. Click on File in the top menu.
Note that you might have to press Alt to show the top menu on Windows and Linux.
  1. Select Save Workspace as....

file save workspace-as

  1. Give your workspace a name and save it.
Make sure to stick with the default location of where the workspace is saved.

The file will have a .code-workspace extension.

The file stores your workspace configuration, so it can be used to open it.

You can open your workspace from a file in multiple ways:

  1. Double-click on the file with .code-workspace extension (assuming VS Code is your default application for opening such files).
  2. Click on File in the top menu, select Open Workspace from File and select the .code-workspace file.

open workspace from file

I've also written an article on how to rename a file, folder or workspace in VS Code.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.