Autosave feature in VSCode
Tired of forgetting to save files in VS Code? Learn how to easily enable the Autosave feature, set it to onFocusChange, and never lose unsaved changes again!
This article is over a year old but was reviewed on July 30, 2026 — the content is still accurate.
This article is part of the VSCode - Tips, extensions and shortcuts series:
- Markdown folding not working
- Start vscode from github.com
- Sticky scroll in vscode
- Autosave feature in VSCode
- Error Lens addon for VSCode
- CodeSnap addon for VSCode
- Export the list of extensions you've installed in VSCode
- Multiple cursors in vscode
- PHP Getter and Setter in VSCode
- Working with regions in VSCode
- Using the JetBrains Mono font in vscode
- Todo Tree in VSCode
- Do I need VSCode on my machine to use it?

This article shows how to enable VSCode's Autosave feature, either through the Settings UI (Files: Auto save set to onFocusChange) or by adding the corresponding line to settings.json, so changes are saved automatically whenever the editor loses focus instead of relying on manual Ctrl+S.
How many times have you modified a file in VSCode (and forgotten to save the modification) in order to refresh it from your web page, run the script from your console, etc., and then thought Oh no, damn, it still doesn't work?
And it can take several minutes of back and forth before — damn it, silly me — you realize you didn't save your changes.
And even more so when you've done a Search & Replace in several files; some having been saved and others not — think of a multiple cursors session spread across a dozen tabs.
Let's see how to avoid this.
It's really easy: press CTRL-, (comma) to show the settings page and start to type autosave.
The concerned settings will be displayed and set Files: Auto save on onFocusChange.

Or, you can also simply add the following line in your settings.json file:
{ "files.autoSave": "onFocusChange"}This is a VS Code settings configuration that tells the editor to automatically save files whenever the editor window loses focus—that is, when you switch to a different application or window.
You're using a versioning system, right?
Some people don't like this feature and say I want to be aware when I save something (in case I do something stupid eh) but, oh, there's a versioning system like Git isn't there? So if you do something stupid, just don't save the changes and/or do a revert.
If you're one of these people, try out the autosave function for a few days, and you'll see that it brings undeniable comfort.
Another setting in the same spirit, one you enable once and never think about again: Sticky scroll in VSCode.
This article is part of the VSCode - Tips, extensions and shortcuts series:
- Markdown folding not working
- Start vscode from github.com
- Sticky scroll in vscode
- Autosave feature in VSCode
- Error Lens addon for VSCode
- CodeSnap addon for VSCode
- Export the list of extensions you've installed in VSCode
- Multiple cursors in vscode
- PHP Getter and Setter in VSCode
- Working with regions in VSCode
- Using the JetBrains Mono font in vscode
- Todo Tree in VSCode
- Do I need VSCode on my machine to use it?





