Skip to content

How to autosave code in Visual Studio Code editor?

Last updated on July 7, 2023

To enable autosave functionality in Visual Studio Code, you can follow these steps:

  1. Open Visual Studio Code.
  2. Go to the “File” menu and select “Preferences”, then click on “Settings”. Alternatively, you can use the shortcut Ctrl + , (Cmd + , on macOS) to open the settings directly.
  3. The settings window will open with the default settings on the left and your user settings on the right. Look for the “Files: Auto Save” option and click on the pencil icon to edit it.
  4. Choose one of the available options:
    • "off": Disables autosave.
    • "afterDelay": Saves files after a certain delay (configured by "files.autoSaveDelay").
    • "onFocusChange": Saves files when the editor loses focus.
    • "onWindowChange": Saves files when the VS Code window loses focus.
    • "onWindowChangeOrBlur": Saves files when the VS Code window loses focus or is minimized.
  5. Select your preferred autosave option by clicking on it.
  6. Close the settings window. Visual Studio Code will automatically save your preferences.

By enabling autosave, any changes you make in your code will be automatically saved based on the chosen autosave option. This helps to reduce the risk of losing unsaved work and ensures that your code is continuously saved without manual intervention.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments