To prevent opening any previously opened workspace when starting VS Code without a resource (file/directory/code-workspace) argument, put "window.restoreWindows": "none",
in settings.json.
To handle editor tabs for untitled (new, unsaved) files, put "files.hotExit": "off",
in settings.json. See also How can I get VS Code to not remember unsaved changes when I exit it?.
From my basic testing, the two above measures don't prevent VS Code from recalling open editors and editor groups when reopening a previously opened workspace. There's at least one trick that I know of to work around this. You can put the following task in a workspace tasks.json file to make VS Code close all editor groups for that workspace on startup, or put it in your user-level tasks (run Tasks: Open User Tasks
) file to make it run on open for all workspaces:
{
"label": "close editor groups",
"command": "${command:workbench.action.closeAllGroups}",
"runOptions": {
"runOn": "folderOpen",
},
"presentation": {
"echo": false,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false,
},
},
If you want to run that command manually instead of automatically, then just run View: Close All Editor Groups
in the command palette.
For other stuff, see settings like terminal.integrated.hideOnStartup
, workbench.editor.restoreViewState
, or related commands that you can do something similar with the above folderOpen task.
There are feature requests about this:
Untitled-1
tab. It drives me nuts"window.reopenFolders" : "all"
opens every single file no matter if it is in the currently active directory or not. Sadly it seems that VS code still doesn't support having multiple active directories because of all that "active directory = workspace"."window.reopenFolders" : "all"
. To test, 1) go toFile>Close Folder
, 2) drag and drop any random file into VS Code, 3) go toFile>Exit
, 4) Relaunch VS Code, 5) Notice you get a blank VS Code editor again. In order to restore sessions, you need to have an active directory open. Any session, regardless of file location, will be remembered as long as you have an active directory. Btw, you can installProject Manager
extension to jump between multiple active directories.