Your Search Bar For Shrewd Tips

How To Close Vs Code Folder


Knowing how to close a VS Code folder is useful when you finish a task, need to switch projects, or want to open a single file without keeping a project workspace active. Closing a folder does not usually close the Visual Studio Code application. Instead, it removes the current folder or workspace from the window, leaving you free to open another project or continue working with individual files. This guide explains the quickest ways to close a folder, what happens to your files and settings, and how to reopen your project afterward.

What “Close Folder” Does in VS Code

In Visual Studio Code, a folder is the project directory currently open in the editor. It appears in the Explorer panel and provides context for project files, source control, extensions, and workspace settings. When you close that folder, VS Code clears the project from the current window. The application itself stays open unless you choose a separate command to close the window or quit VS Code.

If you opened a multi-root workspace—a workspace containing several folders—the menu may say Close Workspace instead of Close Folder. In either case, the effect is similar: the current project context is removed from the window. Closing a folder does not delete it from your computer or erase its files.

Close a Folder from the File Menu

The most straightforward way to close a folder is through the VS Code menu. This method is easy to remember and works well if you do not know the keyboard shortcut.

  • Save any files you have changed, or review the save prompt if one appears.
  • Open the File menu at the top of the VS Code window.
  • Select Close Folder.
  • If you have a multi-root workspace open, select Close Workspace when that is the option shown.

After you select the command, the Explorer will no longer show the project’s folder tree. Depending on your VS Code version and window setup, you may see an empty editor area, a welcome screen, or any open files that are not tied to the closed project. You can then open another folder or open a file directly.

If you do not see Close Folder, check whether the window is displaying a workspace. The corresponding command may be labeled Close Workspace. Menu names and available commands can also vary slightly between VS Code versions and configurations.

Use the Keyboard Shortcut to Close a Folder

For a faster workflow, use VS Code’s default close-folder shortcut. On Windows and Linux, press Ctrl+K, then press F. On macOS, press Cmd+K, then press F. Enter the keys in sequence rather than holding them all down at once.

Keyboard shortcuts can be changed, and extensions or custom keybindings may affect how a command behaves. If the shortcut does not work, use the menu or look up the command in Keyboard Shortcuts:

  • Open the File menu and check the shortcut displayed beside Close Folder or Close Workspace.
  • Open Keyboard Shortcuts with Ctrl+K, Ctrl+S on Windows or Linux, or Cmd+K, Cmd+S on macOS.
  • Search for Close Folder or Close Workspace to view or edit the assigned shortcut.

Using the shortcut closes the project context in the current window. It does not remove the project from your computer and is not the same as closing VS Code entirely.

Close a Folder with the Command Palette

The Command Palette is another reliable option, especially if you cannot find the menu item or prefer to use keyboard navigation. It lets you search for VS Code commands by name.

  • Open the Command Palette with Ctrl+Shift+P on Windows or Linux, or Cmd+Shift+P on macOS.
  • Type Close Folder or Close Workspace.
  • Select the matching command from the results.

The Command Palette may list different options depending on what is open. If you have a regular folder open, search for File: Close Folder. If you have a saved multi-root workspace open, look for File: Close Workspace. Selecting the relevant command closes the current project in the same way as using the File menu.

This method is also helpful when you remember what you want to do but not where the command appears. The palette can find many other useful actions, such as opening a folder, switching workspaces, or reopening a recently used project.

Close a Folder Without Closing VS Code

It is important to distinguish between closing a folder and closing a VS Code window. Choose Close Folder when you want to clear the project from the current window but keep the application running. Choose Close Window when you want to close that window, including its editor tabs. Choose Exit or Quit Visual Studio Code when you want to close the application.

On Windows and Linux, Ctrl+Shift+W commonly closes the current window. On macOS, Cmd+Shift+W commonly performs the same action. These shortcuts are not the same as the close-folder shortcut. If you only intend to switch projects, use File > Close Folder or the Command Palette to avoid closing the whole window by mistake.

After closing a folder, you can keep working in the same VS Code window. For example, you could open a file from another location, use the welcome screen to select a project, or open a different folder from the File menu. This is convenient when you want to move between projects without quitting the editor.

What Happens to Unsaved Files?

Closing a folder does not automatically mean that your unsaved changes are discarded. If an editor contains changes that have not been saved, VS Code will generally prompt you to save, discard, or cancel before completing an action that would close the file or window. Read the prompt carefully and choose the option that matches what you want.

  • Select Save to keep the latest changes in the file.
  • Select Don’t Save only if you are sure you want to discard the unsaved changes.
  • Select Cancel if you want to return to the editor without closing the folder.

For peace of mind, save important files before closing a folder. You can save the active file with Ctrl+S on Windows or Linux, or Cmd+S on macOS. To save all open files, use File > Save All, or search for Save All in the Command Palette.

Closing a folder also does not delete files, remove source control history, or uninstall project dependencies. It only changes what is currently open in the editor. Any effects related to unsaved work depend on your choices in the save prompt and your editor settings.

Close a Folder and Open Another Project

If your goal is to switch projects, you can either close the current folder first or open the next folder directly. To close the current project and then choose another, select File > Close Folder, followed by File > Open Folder. Browse to the project directory, select it, and confirm the choice.

You can also use File > Open Recent to reopen a project you have used before. Select the folder or workspace from the recent-items list. Depending on your settings and the command you choose, VS Code may open the project in the current window or a new window.

Opening another folder directly can be quicker than closing the current one first. Select File > Open Folder, choose the new project, and confirm. VS Code may ask whether to open it in the current window or a new one. Choosing the current window replaces the active project context; choosing a new window keeps both projects available in separate windows.

If you want to save a project arrangement that includes multiple folders, use a multi-root workspace rather than repeatedly opening and closing separate folders. A workspace can be saved and reopened later, keeping its folder list and workspace-specific settings together.

Close One Editor Tab, Not the Folder

Sometimes “close folder” means something different to a user: they may want to close a file tab while leaving the project open. To close only the active editor tab, use the tab’s close button or select File > Close Editor. The folder remains visible in Explorer, and the rest of the project stays open.

To close all open editor tabs without closing the project, look for Close All Editors in the File menu or Command Palette. This is useful when you want a clean editor area but still need access to the current folder’s files, search results, and project tools.

In short, use Close Editor for one tab, Close All Editors for all tabs, and Close Folder or Close Workspace to remove the project context from the window.

Troubleshooting: The Folder Will Not Close

If the folder appears to remain open, first check whether VS Code is waiting for a save decision. A dialog may be behind another window or hidden by the application. Save or resolve the prompt, then try the close command again.

If a shortcut does nothing, use the Command Palette to run the close command directly. You can also check your keybindings for a conflict or changed shortcut. If the expected command is absent, confirm that a folder or workspace is actually open and check the File menu for the available option.

If VS Code closes instead of just clearing the folder, you may have selected Close Window or Exit. Reopen VS Code and restore the project through File > Open Recent or File > Open Folder. Your project files remain in their original location unless you separately delete or move them outside the editor.

Conclusion

To close a VS Code folder, select File > Close Folder, use the Command Palette, or press the close-folder shortcut for your operating system. For a multi-root project, choose Close Workspace if that is the command shown. This removes the project from the current window without deleting its files or necessarily closing VS Code. Save any important edits, then reopen a folder, choose a recent project, or continue with individual files. Knowing the difference between closing a tab, a folder, a window, and the application makes switching projects safer and quicker.


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 →