Introduction

VS Code's auto save feature protects you from losing work by automatically saving your files. When it stops working, you risk losing changes if VS Code crashes or you forget to save manually. This guide covers the common reasons auto save fails and how to fix each one.

Symptoms

  • Files show as modified (dot in tab) but don't save automatically
  • Changes are lost when VS Code closes unexpectedly
  • Auto save works sometimes but not always
  • Auto save only works for certain file types
  • Files save to wrong location

Quick Check

Verify auto save is enabled:

json
// settings.json
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000

Or open Settings (Ctrl+,) and search for "auto save".

Step-by-Step Fixes

Step 1: Enable Auto Save

The first thing to check is whether auto save is actually enabled:

json
// settings.json
"files.autoSave": "afterDelay"

Options for files.autoSave: - "off": Manual save only (default) - "afterDelay": Save after autoSaveDelay milliseconds - "onFocusChange": Save when editor loses focus - "onWindowChange": Save when VS Code window loses focus

Choose the mode that fits your workflow:

```json // settings.json - Recommended for most users "files.autoSave": "afterDelay", "files.autoSaveDelay": 1000 // Save after 1 second of inactivity

// Alternative: Save when switching files "files.autoSave": "onFocusChange"

// Alternative: Save when leaving VS Code "files.autoSave": "onWindowChange" ```

Step 2: Adjust Save Delay

If auto save feels too slow or too aggressive:

json
// settings.json
"files.autoSaveDelay": 1000  // 1 second (default)

Common values: - 1000: Save after 1 second (recommended) - 500: More aggressive, save after half second - 2000: Less intrusive, save after 2 seconds - 5000: Very patient, save after 5 seconds

Step 3: Check Workspace Settings Override

Workspace settings can override user settings:

  1. 1.Open .vscode/settings.json in your project
  2. 2.Check for "files.autoSave": "off"
  3. 3.Remove or change the setting
json
// .vscode/settings.json
{
    "files.autoSave": "afterDelay"  // Ensure this is not "off"
}

Step 4: Check for Language-Specific Overrides

Auto save may be disabled for specific file types:

json
// settings.json - Check these
"[markdown]": {
    "files.autoSave": "onFocusChange"  // Could be "off"
}

Remove any language overrides that disable auto save.

Step 5: Verify File Is Not Excluded

VS Code may not auto save excluded files:

json
// settings.json
"files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true
},
"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/**": true
}

Files in these locations won't be auto saved.

Step 6: Check for Dirty File Handling

VS Code may prompt before saving certain files:

json
// settings.json
"files.saveConflictResolution": "askUser"

This can block auto save if there's a conflict. Change to:

json
"files.saveConflictResolution": "acceptLocalChanges"

Step 7: Fix Hot Exit Interference

Hot exit saves your state when VS Code closes. It can interact with auto save:

json
// settings.json
"files.hotExit": "onExit",
"files.restoreUndoStack": true

If hot exit is disabled, your changes may not persist:

json
"files.hotExit": "onExitAndWindowClose"  // Most protective

Step 8: Check Git Integration

Git can affect saving behavior:

json
// settings.json
"git.enableSmartCommit": true,
"git.smartCommitChanges": "all",
"git.autoSaveDelay": 1000,
"git.autoSave": "afterDelay"

Note: These are Git-specific auto save settings for before commits, different from general auto save.

Step 9: Handle Large Files

Large files may not auto save due to memory limits:

json
// settings.json
"files.maxMemoryForLargeFilesMB": 4096

Files exceeding this limit may not auto save properly.

Step 10: Check Encoding Issues

Encoding problems can prevent saving:

json
// settings.json
"files.encoding": "utf8",
"files.autoGuessEncoding": true

If a file has unusual encoding, VS Code may fail to auto save it.

Step 11: Fix Read-Only Files

Read-only files cannot be auto saved. Check file permissions:

Windows: ```powershell # Check if file is read-only Get-ItemProperty "path\to\file" | Select-Object IsReadOnly

# Remove read-only attribute Set-ItemProperty "path\to\file" -Name IsReadOnly -Value $false ```

macOS/Linux: ```bash # Check permissions ls -la "path/to/file"

# Make writable chmod u+w "path/to/file" ```

Step 12: Handle Network Drive Issues

Files on network drives may have auto save issues:

json
// settings.json
"files.autoSave": "onWindowChange",  // More reliable for network files
"files.autoSaveDelay": 3000  // Longer delay for network latency

Step 13: Check Extension Conflicts

Extensions can affect saving behavior:

  1. 1.Open Extensions (Ctrl+Shift+X)
  2. 2.Search for "save" or "auto"
  3. 3.Disable suspicious extensions
  4. 4.Test if auto save works

Extensions that might interfere: - Vim extension (may have its own save behavior) - Save-related utilities - Git extensions with save hooks

Step 14: Verify Save Is Happening

Check if saving is occurring silently:

  1. 1.Open a file and make changes
  2. 2.Wait for auto save delay
  3. 3.Check the tab - the dot should disappear
  4. 4.Look at Output panel: Ctrl+Shift+U, select "Log (Window)"
  5. 5.Search for "save" messages

If you see errors:

bash
Error saving file: Permission denied
Unable to save: File is read-only

Address those specific errors.

Platform-Specific Issues

Windows

UAC and antivirus can block auto save:

  1. 1.Check if VS Code has write permissions
  2. 2.Add project folder to Windows Defender exclusions
  3. 3.Run VS Code as administrator to test

macOS

macOS sandbox can restrict saving:

  1. 1.Check Files and Folders permissions in System Preferences
  2. 2.Ensure VS Code has access to your project folders
  3. 3.Try moving project to a non-protected location

Linux

Permissions and filesystem issues:

```bash # Check if you own the files ls -la

# Fix ownership chown -R $USER:$USER ~/projects ```

Verification

Test auto save is working:

  1. 1.Open a file
  2. 2.Make a change
  3. 3.Wait for autoSaveDelay seconds
  4. 4.Check if the tab's dot disappears
  5. 5.Close VS Code without manually saving
  6. 6.Reopen VS Code
  7. 7.Verify your changes are present

Best Practices

json
// settings.json - Recommended configuration
{
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 1000,
    "files.hotExit": "onExitAndWindowClose",
    "files.encoding": "utf8",
    "files.eol": "\n",
    "files.insertFinalNewline": true,
    "files.trimFinalNewlines": true,
    "files.trimTrailingWhitespace": true
}
  • VS Code Word Wrap Not Working
  • VS Code Format on Save Not Working
  • VS Code Settings Not Saving