83

Does anyone know where VS code saves unsaved files on a Windows machine?

I have found many discussions about this features, but they don't mention where the files are actually saved.

Burgi
  • 6,768
Josh
  • 833

7 Answers7

80

The Microsoft help file indicates that the settings are stored in the folder:

Windows - %APPDATA%\Code\User\

For me this translated to:

C:\Users\USERNAME\AppData\Roaming\Code\

In this folder I located a Backups folder, this folder contained the raw data for my document. This appears to be grouped by date stored as a UNIX timestamp.

VS Code cached document location

Burgi
  • 6,768
37

For Linux users they are found at ~/.config/Code/Backups.

Alex
  • 570
28

For Visual Studio Code on macOS, these files are found at:

~/Library/Application Support/Code/Backups

Insiders on macOS:

~/Library/Application Support/Code - Insiders/Backups

OSS on macOS:

~/Library/Application Support/Code - OSS/Backups
evan.bovie
  • 3,342
3

VS Code has a "Hot Exit" feature that keeps records of files that have unsaved changes when the window is closed so that it can present those unsaved versions the next time it reopens.

Hot Exit file contents are stored under the Backups directory under the user data directory. The default user data directory location varies by platform (you can also specify a custom location when opening VS Code via commandline (--user-data-dir)). See https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations.

  • Windows %APPDATA%\Code
  • macOS $HOME/Library/Application\ Support/Code
  • Linux $HOME/.config/Code
  • For VS Code Server, the default user data directory should be ~/.vscode-server/data

Be warned that the file names are not human-readable, but the file contents should start with a line containing the file's path (unless the file is "Untitled" (has never been saved before)). Tools like grep or ripgrep can help if you have a search string (file name or contents) you can look for.

starball
  • 286
  • 1
  • 2
  • 13
2

If you use scoop on Windows to manage your (portable) vscode installation, the backup path you're looking for is

%USERPROFILE%\scoop\persist\vscode-portable\data\user-data\backups
2

If all else fails, you may find part or all of your unsaved content in the following location:

C:\Users\USERNAME\AppData\Roaming\Code\User\History

I accidentally permanently deleted a file from my disk that didn't have any backup. Even tried those 3rd-party undelete tools, but couldn't find the file. Then I found this post and tried to locate an unsaved version, but there was none. Then just cruising through the directories I found location and therein was my content waiting to be discovered.

Note that VSCode uses hashed file names and there may be lots of subfolders in this location, so a manual find might be tedious. Instead you can open the entire History folder in VSCode (Open Folder command) and then use global text search to find your file(s). Also note that it stores several copies of each file over time, so u may want to cruise through found files to get the latest version.

dotNET
  • 569
-3

Windows, Visual Studio 2019:

%localappdata%\Microsoft\VisualStudio\BackupFiles
simaglei
  • 115