How to quickly toggle (enable/disable) autosave in VS Code
To enable or disable autosave in VS Code, use the
File > Auto Save option from the menu bar.
After this, the "dirty" indicator will no longer show up when you modify a saved file.
Why do we need autosave?
So we can stop mindlessly pressing
Ctrl + S.
So we can save time, increase productivity, and be much more certain that we're working with the latest changes.
Autosave is not perfect though; it's up to you to weigh the pros and cons - which we comprehensively cover here.
What's not to like about autosave?
Some of the cons we talk about in that autosave article:
- It wastes resources because it saves even when you're not ready to view the results of your changes.
- It makes it harder to recover from unexpected errors, for example, making a buggy file change and accidentally closing the file.
- There's no auto-formatting with auto-save.
Enable/disable autosave in VS Code Settings
Alternatively, we can disable autosave in Visual Studio Code using the
Files: Auto Save setting in the
You can easily navigate to this page with the gear icon at the top-left of the code editor:
Once you get there, you can use the search bar to find the setting.
As you can see,
Files: Auto Save can be one of four possible values, namely:
off- self-explanatory: disable autosave.
afterDelay: - the new value enables autosave with the
File > Auto Savesetting. autosaves the file sometime after your changes.
onFocusDelay- autosaves the dirty file when you switch windows or tabs.
onWindowChange- as the name implies, autosaves the unsaved file when you switch windows in the operating system.
So there are more customization options in the
Settings page than in the menu bar.
Change autosave delay in VS Code
Files: Auto Save is set to
afterDelay, you can modify the autosave delay in Visual Studio Code with the
Files: Auto Save Delay setting.
You may be better off increasing the autosave delay instead of disabling autosave entirely, so VS Code still saves your work automatically, while minimizing the impact on system resources.
Enable/disable autosave in VS Code with Command Palette
To turn autosave on or off in Visual Studio Code, you can also use the
File: Toggle Auto Save command, accessible from the Command Palette:
11 Amazing New Features in ES13
- How to easily fix the "Command not found" error in VS Code
- How to Quickly Reveal the Current File in Explorer in VS Code
- Quickly open Markdown link in new tab (target _blank)
- [SOLVED] "auth/unauthorized domain" error in Firebase Auth
- How to Get the Window's Width on Resize in React