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:
// settings.json
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000Or 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:
// 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:
// 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.Open
.vscode/settings.jsonin your project - 2.Check for
"files.autoSave": "off" - 3.Remove or change the setting
// .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:
// 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:
// 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:
// settings.json
"files.saveConflictResolution": "askUser"This can block auto save if there's a conflict. Change to:
"files.saveConflictResolution": "acceptLocalChanges"Step 7: Fix Hot Exit Interference
Hot exit saves your state when VS Code closes. It can interact with auto save:
// settings.json
"files.hotExit": "onExit",
"files.restoreUndoStack": trueIf hot exit is disabled, your changes may not persist:
"files.hotExit": "onExitAndWindowClose" // Most protectiveStep 8: Check Git Integration
Git can affect saving behavior:
// 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:
// settings.json
"files.maxMemoryForLargeFilesMB": 4096Files exceeding this limit may not auto save properly.
Step 10: Check Encoding Issues
Encoding problems can prevent saving:
// settings.json
"files.encoding": "utf8",
"files.autoGuessEncoding": trueIf 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:
// settings.json
"files.autoSave": "onWindowChange", // More reliable for network files
"files.autoSaveDelay": 3000 // Longer delay for network latencyStep 13: Check Extension Conflicts
Extensions can affect saving behavior:
- 1.Open Extensions (
Ctrl+Shift+X) - 2.Search for "save" or "auto"
- 3.Disable suspicious extensions
- 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.Open a file and make changes
- 2.Wait for auto save delay
- 3.Check the tab - the dot should disappear
- 4.Look at Output panel:
Ctrl+Shift+U, select "Log (Window)" - 5.Search for "save" messages
If you see errors:
Error saving file: Permission denied
Unable to save: File is read-onlyAddress those specific errors.
Platform-Specific Issues
Windows
UAC and antivirus can block auto save:
- 1.Check if VS Code has write permissions
- 2.Add project folder to Windows Defender exclusions
- 3.Run VS Code as administrator to test
macOS
macOS sandbox can restrict saving:
- 1.Check Files and Folders permissions in System Preferences
- 2.Ensure VS Code has access to your project folders
- 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.Open a file
- 2.Make a change
- 3.Wait for
autoSaveDelayseconds - 4.Check if the tab's dot disappears
- 5.Close VS Code without manually saving
- 6.Reopen VS Code
- 7.Verify your changes are present
Best Practices
// 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
}Related Issues
- VS Code Word Wrap Not Working
- VS Code Format on Save Not Working
- VS Code Settings Not Saving