How to Prevent VSCode from Losing Unsaved Tabs Across Multiple Windows

If you frequently work with multiple VSCode windows and use tabs as temporary snippet storage, you might have encountered this frustrating scenario: when closing a window, VSCode prompts you to save unsaved files—even though it usually preserves them automatically in single-window mode. This happens because VSCode’s default hotExit behavior changes when multiple windows are open. Fortunately, you can configure it to always back up unsaved files, regardless of how many windows you have running. The Fix Add this setting to your VSCode settings.json: "files.hotExit": "onExitAndWindowClose" What This Does Default ("onExit") → Only backs up unsaved files when closing the last remaining window. "onExitAndWindowClose" → Ensures unsaved files are preserved even when closing individual windows. Now you can close windows freely without losing work—ideal for those temporary scratch tabs!

Mar 29, 2025 - 21:37
 0
How to Prevent VSCode from Losing Unsaved Tabs Across Multiple Windows

If you frequently work with multiple VSCode windows and use tabs as temporary snippet storage, you might have encountered this frustrating scenario: when closing a window, VSCode prompts you to save unsaved files—even though it usually preserves them automatically in single-window mode.

This happens because VSCode’s default hotExit behavior changes when multiple windows are open. Fortunately, you can configure it to always back up unsaved files, regardless of how many windows you have running.

The Fix

Add this setting to your VSCode settings.json:

"files.hotExit": "onExitAndWindowClose"

What This Does

  • Default ("onExit") → Only backs up unsaved files when closing the last remaining window.
  • "onExitAndWindowClose" → Ensures unsaved files are preserved even when closing individual windows.

Now you can close windows freely without losing work—ideal for those temporary scratch tabs!