How to close an opened folder in Visual Studio Code?

Visual Studio-Code

Visual Studio-Code Problem Overview


I love VSCode. But I can't find a way to close an opened folder. It seems that you can only open one folder at a time. And the only way to close it is to close the whole program?

Am I missing something?

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

The command to close the currently opened folder can be found from File -> Close Folder.

You can also use the shortcut:

Ctrl+K F

(press and hold Ctrl, then press and release K, then release Ctrl, and then press F)

And on a Mac:

āŒ˜+k f

Solution 2 - Visual Studio-Code

With the 0.3.0 update we added a new command to close a folder. You can find it under the File menu.

Solution 3 - Visual Studio-Code

VSCode doesn't have an explicit close folder gesture yet. You can either select File > Open Folder in a open windows of VSCode or select File > New Window and in there File > Open. Having multiple open folders inside a single window isn't supported.

Solution 4 - Visual Studio-Code

As VS Code remembers the last session when opened, you can:

  1. open New Window (Ctrl+Shift+N) - this will open new VS Code with no project folders opened,
  2. close the old window (with opened project folder),
  3. close the new one.

Next time you run VS Code, it should look like the last window you closed and thus without any folders opened.

Note that this process closes ALL opened folders.

Solution 5 - Visual Studio-Code

For all what you have in your mind for "Visual Studio Code" use simply "Command Palette" throught

> menu: VS Code / View / Command Palette... > > keyboard: CMD / CTRL + SHIFT + P

and then you can find all by text.

> text: Close All Editors > > keyboard: CMD / CTRL + K + W

Also you can find and redefine all "Key Bindings" here

> menu: VS Code / Code / Preferences / Keyboard Shortcuts > > keyboard: CMD / CTRL + K + S

Solution 6 - Visual Studio-Code

if open a folder in workspace ( File > Add Folder to Workspace ) you can close folder with [ right click on folder name > remove folder from workspace ] but if you open folder from (file > open folder) you can close with [File > Close Folder]

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionskyline75489View Question on Stackoverflow
Solution 1 - Visual Studio-CodeforethoughtView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeBenjamin PaseroView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeJohannes RiekenView Answer on Stackoverflow
Solution 4 - Visual Studio-CodegiusView Answer on Stackoverflow
Solution 5 - Visual Studio-CodeBGBRUNOView Answer on Stackoverflow
Solution 6 - Visual Studio-CodeaazimkhaniView Answer on Stackoverflow