How do I configure VS Code to automatically save files?
Jul 01, 2025 am 12:47 AMYes, VS Code can automatically save files. To enable auto-save, go to File > Auto Save (Windows/Linux) or Code > Auto Save (macOS), and check the box. You can also set it to save on focus change by adding "files.autoSave": "onFocusChange" to settings.json. For more control, use extensions like "Auto Saver for VS Code" or "Save and Notify", which offer customization options. Additionally, combine auto-save with other settings like "editor.formatOnSave": true for formatting on save. While auto-save minimizes data loss, it doesn’t fully protect against crashes, so backups or version control are still recommended.
Yes, VS Code can automatically save files — and it's actually one of the first things many users want to set up after installing the editor. The good news is that it’s built-in and not hard to configure, but there are a few options depending on what exactly you're looking for.
Enable Auto Save
The most straightforward way to get files to save automatically in VS Code is by turning on the "Auto Save" feature. When enabled, any changes you make to a file will be saved automatically after a short delay (or when you focus out of the editor, depending on your settings).
To enable it:
- Open VS Code
- Go to
File > Auto Save
(on Windows/Linux) orCode > Auto Save
(on macOS) - Check the box to turn it on
By default, it uses the mode called afterDelay
, which means it saves periodically. If you prefer saving to happen only when you leave the editor window (like clicking outside the editor or switching windows), you can change the setting like this:
"files.autoSave": "onFocusChange"
Add that line to your settings.json
file in VS Code.
Use Extensions for More Control
If the built-in auto-save doesn't give you enough flexibility, there are extensions that offer more advanced behavior. One popular option is "Auto Saver for VS Code" or "Save and Notify", which let you customize when and how files are saved. Some even allow notifications when a file is saved, or let you exclude certain file types from auto-saving.
Here’s how to use an extension:
- Go to the Extensions view (
Ctrl Shift X
or click the Extensions icon on the sidebar) - Search for “auto save”
- Pick one with good ratings and install it
- Check the extension’s documentation for any extra configuration
Keep in mind that while extensions can add features, they may also introduce overhead or conflicts, especially if you have several running at once.
Combine Auto Save with Other Settings
Auto save works best when paired with other related settings. For example, if you’re using Prettier or another formatter, you might want to ensure it runs on save. To do that, enable:
"editor.formatOnSave": true
Also, if you're working with Git or source control, auto-saving helps reduce the number of unsaved changes showing up in your diff tools.
One thing to watch: auto save doesn’t prevent you from losing work if VS Code crashes — though it does minimize the risk. If you're working on critical files, always make sure you have backups or version control in place.
That’s basically all. Whether you stick with the built-in auto save or go for an extension depends on how much control you need. Either way, it’s not complicated — just a couple of settings away.
The above is the detailed content of How do I configure VS Code to automatically save files?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The differences in pricing, licensing and availability of VisualStudio and VSCode are as follows: 1. Pricing: VSCode is completely free, while VisualStudio offers free community and paid enterprise versions. 2. License: VSCode uses a flexible MIT license, and the license of VisualStudio varies according to the version. 3. Usability: VSCode is supported across platforms, while VisualStudio performs best on Windows.

VisualStudio is suitable for large projects, VSCode is suitable for projects of all sizes. 1. VisualStudio provides comprehensive IDE functions, supports multiple languages, integrated debugging and testing tools. 2.VSCode is a lightweight editor that supports multiple languages ??through extension, has a simple interface and fast startup.

VisualStudio is suitable for large projects and Windows development, while VSCode is suitable for cross-platform and small projects. 1. VisualStudio provides a full-featured IDE, supports .NET framework and powerful debugging tools. 2.VSCode is a lightweight editor that emphasizes flexibility and extensibility, and is suitable for various development scenarios.

SublimeText is more suitable for users who work with large files and prefer lightweight editors, while VSCode is more suitable for users who need IDE capabilities and powerful scalability. 1.SublimeText is known for its speed and simplicity, and is suitable for handling large files. 2.VSCode is known for its scalability and Microsoft support, and is suitable for users who need IDE capabilities.

VisualStudio is suitable for large-scale project development, while VSCode is suitable for projects of all sizes. 1. VisualStudio provides comprehensive development tools, such as integrated debugger, version control and testing tools. 2.VSCode is known for its scalability, cross-platform and fast launch, and is suitable for fast editing and small project development.

SublimeTextisidealforthosevaluingspeedandsimplicity,whileVSCodesuitsthoseneedingextensivefeaturesandcustomization.SublimeTextoffersquickfileaccesswith"GotoAnything"andaminimalisticapproach,butmaylackout-of-the-boxfunctionality.VSCodeprovide

SublimeText is suitable for developers who pursue speed and simplicity, while VSCode is suitable for users who need strong scalability and integration capabilities. 1.SublimeText is known for its lightweight and fast response, with GotoAnything and multi-select powerful. 2. VSCode is known for its scalability and IDE functions, with built-in Git and debugging tools, and IntelliSense improves development efficiency.

VisualStudio and VSCode have their own advantages and disadvantages, which are suitable for different development needs. VisualStudio is suitable for large projects and provides rich functions; VSCode is lightweight, flexible, and has cross-platform support.
