Your Search Bar For Shrewd Tips

How To Close Workspace In Vs Code


Knowing how to close a workspace in VS Code helps you switch projects, tidy up your editor, or return to the Welcome screen without accidentally deleting files. The process is quick, but the right option depends on whether you opened a single folder, a multi-root workspace, or a saved .code-workspace file. This guide explains how to close a workspace in Visual Studio Code using the File menu, Command Palette, and keyboard shortcuts, and what to expect when unsaved changes or multiple folders are involved.

What Closing a Workspace in VS Code Does

Closing a workspace ends your current project session in the VS Code window. It removes the project’s folders from the Explorer and closes the workspace context, but it does not delete your project files from your computer. Your source code, images, and other files remain wherever they were stored.

A workspace can represent a single folder or several folders grouped together. You can also save a multi-folder setup as a .code-workspace file. VS Code uses the word “workspace” broadly, so the command you see may depend on how the current window was opened. For example, a window showing one folder may offer a command to close that folder, while a window containing a saved multi-root workspace may offer “Close Workspace.” Both actions end the current project session in that window.

Closing a workspace is different from removing one folder from a multi-root workspace. It is also different from closing the VS Code window or quitting the application. Choose the action that matches what you want to do next.

How to Close a Workspace from the File Menu

The File menu is the most straightforward way to close a workspace in VS Code. It is useful if you are still learning the editor or want to confirm the available options before choosing one.

  • Open the VS Code window containing the workspace you want to close.
  • Select File from the menu bar.
  • Choose Close Workspace or, in a single-folder window, Close Folder.
  • If VS Code asks whether to save changes, save or discard them before continuing.

After the workspace closes, the editor may show the Welcome screen, an empty window, or another startup view, depending on your VS Code version and settings. Your files are not removed. To continue working later, reopen the project from the Welcome screen or use the File menu’s open options.

On macOS, the File menu is in the system menu bar at the top of the screen. On Windows and Linux, it is usually at the top of the VS Code window, although the menu bar may be hidden or arranged differently depending on your settings. The command’s wording can vary with the type of project open, so look for the close option that matches your current window.

Close a Workspace with the Command Palette

The Command Palette offers a quick way to find and run VS Code commands without navigating menus. It is especially helpful when the menu bar is hidden or when you do not remember where a command is located.

  • Open the Command Palette using Ctrl+Shift+P on Windows or Linux, or Command+Shift+P on macOS.
  • Type Close Workspace into the search box.
  • Select the matching close command from the results. If your window contains one folder, search for Close Folder if needed.
  • Respond to any save prompt that appears.

You can also open the Command Palette from the View menu or by using the search interface provided in your VS Code version. Search results are contextual: VS Code may show a different close command depending on whether you opened a folder, a saved workspace, or an empty window. If the exact phrase does not appear, try searching for “close” and review the available commands.

Can You Close a Workspace with a Keyboard Shortcut?

VS Code does not necessarily assign a default keyboard shortcut specifically for closing a workspace on every platform or installation. Menu options and available commands are more dependable than memorizing a shortcut that may not exist in your setup. Use the Command Palette to search for the close command, then check the shortcut shown beside it, if one is assigned.

If you frequently close workspaces, you can assign your own shortcut. Open the Keyboard Shortcuts editor by selecting File > Preferences > Keyboard Shortcuts on Windows or Linux, or Code > Settings > Keyboard Shortcuts on macOS. You can also search for Keyboard Shortcuts in the Command Palette.

In the Keyboard Shortcuts editor, search for the close-workspace or close-folder command. If a shortcut is listed, you can use it as shown. To create or change one, select the pencil icon beside the command, press the key combination you want, and confirm it. Choose a combination that does not conflict with a shortcut you rely on elsewhere. If you are unsure, using the Command Palette is a simple alternative.

Close a Multi-Root Workspace or Remove One Folder

A multi-root workspace lets you work with several folders in one VS Code window. The Explorer displays each folder as a separate top-level item. Closing the workspace ends the entire project session and removes all of those folders from the current window. It does not delete any of the folders or the saved workspace file.

If you only want to stop working with one folder while keeping the rest open, do not close the entire workspace. In the Explorer, right-click the folder you want to remove and choose Remove Folder from Workspace. This removes that folder from the current workspace configuration; it does not erase the folder from your drive. The remaining folders stay open in the window.

To close the whole multi-root workspace, use File > Close Workspace or search for the close command in the Command Palette. If you have made changes to the workspace configuration, VS Code may ask you to save them. Saving updates the workspace definition; it does not combine or move your project files.

These choices are useful in different situations. Remove a folder when you are narrowing the project view, and close the workspace when you are finished with the entire group of folders or want to switch to another project.

What Happens to Unsaved Changes?

Before a workspace closes, VS Code may ask you to save changes in open files. A dot or other unsaved indicator on a tab can signal that a file has edits that have not been written to disk. Review the prompt carefully so you do not lose work.

  • Save: Writes your changes to the file and continues with the close action.
  • Don’t Save: Discards the unsaved edits in the affected file.
  • Cancel: Stops the close action so you can return to the workspace.

The wording and layout of the prompt may vary, and VS Code can ask about more than one file. If you are not sure whether you need an edit, save it first. You can always review or revert saved changes later using your version control system, if the project uses one. Be particularly careful when working with configuration files, unsaved code, or files opened from a remote environment.

VS Code can also restore editor tabs and window state when you reopen a project, depending on your settings. Restoration is not a substitute for saving. Always confirm that important file changes have been saved before closing the workspace.

How to Reopen a Closed Workspace

Closing a workspace does not make it difficult to return to the project. You can reopen a folder, a workspace file, or a recent project using the available open options.

  • To reopen a folder, select File > Open Folder and browse to the project directory.
  • To reopen a saved multi-root workspace, select File > Open Workspace from File and choose its .code-workspace file, if that option is available in your version.
  • To reopen a recent project, select it from the File > Open Recent list or the Welcome screen.
  • To start from a clean window, open a new VS Code window and then choose the project you want.

Recent-project lists are a convenience, not a permanent record. If a project does not appear there, browse to its folder or workspace file directly. The saved workspace file stores workspace-level information, such as which folders are included and some workspace settings; your actual project files remain in their original locations.

Close a Workspace, Close a Window, or Quit VS Code?

These actions sound similar but have different results. Close Workspace ends the current project session in the window. Close Window closes that window, which may also close its workspace, while leaving other VS Code windows open. Quit VS Code exits the application and closes all of its windows.

Choose Close Workspace when you want to clear the current project from a window but keep using VS Code. Choose Close Window when you are done with that particular window. Quit the application when you want to exit VS Code completely. If several projects are open in separate windows, closing one workspace or window does not necessarily close the others.

Common Problems When Closing a VS Code Workspace

If you cannot find Close Workspace, first check what is open. A single-folder session may show Close Folder instead. Search for “close” in the Command Palette to see the commands available for the current window.

If the window appears unchanged after closing, check whether another folder or workspace is still open in a different VS Code window. You may also have closed a folder from a multi-root workspace rather than closing the entire workspace. Use the window’s Explorer and title bar to confirm which project is active.

If VS Code will not close the workspace, a save prompt may be waiting for your response. Choose whether to save, discard, or cancel. If the application seems unresponsive, give it a moment to finish writing files before forcing it to quit, especially when working with large files or remote projects.

For remote development, closing the workspace ends the local VS Code session for that remote project, but it does not automatically delete the remote files. Likewise, closing a workspace connected to a development container does not mean the project’s source code has been erased. Check the specific remote or container workflow before removing resources you no longer need.

Conclusion

To close a workspace in VS Code, use File > Close Workspace or search for the close command in the Command Palette. If you opened a single folder, VS Code may display Close Folder instead. Remove an individual folder only when you want to keep the rest of a multi-root workspace open, and review save prompts before leaving so important edits are not lost. Your project files remain on disk after you close the workspace, and you can reopen them from the Welcome screen, the Open Recent list, or their saved folder or .code-workspace file.


Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.

Shrewdnia

Shrewdnia

Shrewdnia is a destination for curious minds seeking clarity, knowledge, and informed perspectives. Through insightful articles and practical guides our passionate team explores a wide range of topics designed to help readers understand the world around them, make smarter decisions, and stay informed in an ever-changing landscape.


💡 Every question sparks discovery, and every perspective enriches the conversation. Share your thoughts and insights in the comments 👇

Back to blog

Leave a comment

JOIN THE SHREWDNIA COMMUNITY FORUM

What do you think?

Have an opinion, experience, or question about this topic? Join the Shrewdnia Forum and share your thoughts with other readers.

Join the Forum →