Knowing how to close a VS Code folder is useful when you finish working on a project, want to switch to another codebase, or need to clear the current workspace without closing the application. Closing a folder is different from closing VS Code: it removes the project from the current window while leaving the editor available. You can do it from the File menu or with a keyboard shortcut, then open another folder whenever you are ready.
This guide explains how to close a folder in Visual Studio Code on Windows, macOS, and Linux. It also covers what happens to unsaved files, how closing a folder differs from removing one in a multi-root workspace, and what to try if the usual command is unavailable.
How to Close a Folder in VS Code
The standard way to close the folder currently open in VS Code is to use the File menu. The exact menu wording can vary slightly depending on your VS Code version and whether you opened a folder or a workspace, but the process is straightforward:
- Open the VS Code window that contains the folder you want to close.
- Select File in the menu bar.
- Choose Close Folder.
- If VS Code asks you to save changes, save or discard them before continuing.
After the folder closes, the window typically shows the VS Code welcome page, an empty editor area, or another start screen. Your VS Code application remains open. Closing the folder does not delete it from your computer; it simply stops displaying that project as the active folder in the current window.
If the File menu shows Close Workspace instead, you may have opened a saved workspace or a multi-root workspace. Use that command to close the workspace in the current window. The difference between folders and workspaces is explained below.
Close a VS Code Folder With a Keyboard Shortcut
You can also close the current folder with a keyboard shortcut. In the default VS Code key bindings, the shortcut is a two-part key chord:
-
Windows and Linux: Press
Ctrl+K, release the keys, then pressF. -
macOS: Press
Command+K, release the keys, then pressF.
It is important to enter the shortcut in sequence. Do not hold down Ctrl or Command while pressing F. First press the initial combination, then press the second key when VS Code displays the key-chord prompt.
Keyboard shortcuts can be changed, and extensions or customized settings may affect them. If the shortcut does not work, use File > Close Folder or check your current key bindings. Open the Keyboard Shortcuts editor from the File > Preferences menu on Windows or Linux, or from Code > Settings on macOS. Search for Close Folder to view or change the assigned shortcut.
What Happens When You Close a Folder?
Closing a folder removes that project from the active VS Code window. The files are not erased, moved, or changed simply because you closed the folder. You can reopen the same folder later using File > Open Folder.
VS Code may ask you to handle unsaved changes before closing. Review the prompt carefully: choose the save option to keep your edits, or choose the discard option only if you are sure you do not need them. If you cancel the prompt, the folder generally remains open so you can continue editing.
Closing the folder also ends its role as the current workspace context. Project-specific settings, source control details, and folder-based tools may no longer appear in that window. Integrated terminal sessions and extension activity can behave differently depending on the terminal, extension, and workspace configuration, so check any running process before closing if it is important.
Most importantly, Close Folder is not the same as deleting a project. It does not remove the folder from your hard drive or cloud storage. To delete project files, use your operating system’s file manager or an appropriate command, and make sure you understand what will be removed.
How to Open Another Folder After Closing One
After closing a folder, you can open another project in the same VS Code window. Select File > Open Folder, browse to the project directory, and confirm your selection. On some systems, the confirmation button may be labeled Select Folder or Open.
You can also start VS Code from a terminal and specify a folder path. For example, the command code /path/to/project opens the folder at that location if the code command is available in your shell. This is convenient when you already have a terminal open in the project directory.
If you want to keep the current project open while opening another one, choose the option to open the new folder in a new window when prompted. This lets you work with multiple projects at the same time. Depending on your settings, VS Code may reuse the existing window, so check the prompt or window behavior if keeping both projects open matters.
Close Folder, Close Workspace, and Remove Folder: What Is the Difference?
These commands sound similar, but they do different jobs. Choosing the right one helps you avoid closing more than you intended.
- Close Folder: Closes the single folder currently open in the window. Use it when you want to leave a project but keep VS Code running.
-
Close Workspace: Closes the current saved or multi-root workspace. A workspace can include multiple folders and may store its own settings in a
.code-workspacefile. - Remove Folder from Workspace: Removes one folder from a multi-root workspace while leaving the workspace and its other folders open.
- Close Window: Closes the current VS Code window. The application may remain open if other VS Code windows are still running.
- Quit VS Code: Exits the application, usually closing all of its windows.
For example, if you added three project folders to one workspace and want to keep working with two, use Remove Folder from Workspace for the one you no longer need. If you want to leave the entire workspace, use Close Workspace. If you opened just one folder and want an empty VS Code window, choose Close Folder.
Removing a folder from a workspace does not delete the folder from your computer. Similarly, closing a workspace file does not erase the workspace configuration. These commands change what VS Code displays and manages in the current window, not the files stored on disk.
How to Close a Folder in a Multi-Root Workspace
A multi-root workspace lets you work with several folders in one VS Code window. The folders appear together in the Explorer panel, and the workspace may also have shared settings. If you want to close only one of those folders, right-click its name in the Explorer and select Remove Folder from Workspace. The label may vary slightly between versions.
To close the entire multi-root workspace, use the relevant command in the File menu, such as Close Workspace. If you want to preserve your current setup for future use, save the workspace before closing it. A saved workspace is commonly represented by a file ending in .code-workspace.
Before removing a folder, check which folder is selected in the Explorer. Removing the wrong one can interrupt your work, although it will not delete the folder itself. If you are unsure whether you are using a regular folder or a multi-root workspace, look at the Explorer: multiple top-level folder names usually indicate a multi-root setup.
Why Can’t I Find the Close Folder Command?
If Close Folder is missing or disabled, start by checking what is open in the current window. You may be looking at a workspace rather than a single folder, in which case the command may be named Close Workspace. You may also have opened an individual file without opening its containing folder. In that situation, there may be no folder workspace to close.
Other troubleshooting steps include:
- Check the active window: Make sure the VS Code window with the project is selected, especially if you have several windows open.
- Review the File menu: Look for a close command that matches the current folder or workspace type.
-
Try the Command Palette: Press
Ctrl+Shift+Pon Windows or Linux, orCommand+Shift+Pon macOS, then search for Close Folder or Close Workspace. - Check key bindings: Search for the close command in Keyboard Shortcuts if its default shortcut has been changed.
- Resolve save prompts: Save or discard pending edits if VS Code is waiting for a decision before closing the folder.
The Command Palette is especially useful when you cannot remember a menu location or shortcut. It searches available VS Code commands and can reveal which close action applies to the current window.
Close a Folder Without Closing the VS Code Window
If your goal is to leave the project but keep VS Code open, choose Close Folder rather than closing the window or quitting the application. This is helpful when you want to return to the welcome page, open a different project, or keep the editor available without the current folder loaded.
If you want to close the project and also dismiss its window, use the window’s close button or the operating system’s window menu. Be aware that this closes the window, not necessarily every VS Code process. Other open VS Code windows may remain active. To exit the application completely, use the application’s Quit command or the operating system’s equivalent.
When you are deciding which action to take, ask whether you want to leave only the project, the current window, or the entire application. Use Close Folder for the project, Close Window for the current window, and Quit to exit VS Code.
Conclusion
To close a VS Code folder, select File > Close Folder or use the default key chord: Ctrl+K, then F on Windows and Linux, or Command+K, then F on macOS. Save any changes you want to keep, and remember that closing a folder does not delete it from your computer.
If you are working with multiple folders, use Remove Folder from Workspace to close just one, or Close Workspace to leave the entire workspace. Once the folder is closed, you can open another project in the same window or start a separate VS Code window. Understanding these options makes it easier to switch projects without losing edits or changing files unintentionally.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.