65

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.

0

7 Answers 7

65

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

8
  • 17
    Thanks! On OS X there is a similar folder in ~/Library/Application Support/Code/Backup where my text files were hiding out.
    – Alper
    Aug 31, 2017 at 10:36
  • 1
    What about Linux?
    – Colliot
    Apr 22, 2018 at 9:34
  • 7
    On my Chromebook Linux, I found it in ~/.config/Code/Backups/...
    – apex
    Oct 2, 2018 at 12:22
  • 1
    For those of readers using Azure Data Studio, the path is very nearly the same. Substitute azuredatastudio for code in the searched path.
    – Josh Gust
    Aug 11, 2021 at 16:03
  • 1
    you saved my f**king life Sep 27, 2022 at 0:42
33

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

4
  • 3
    ~/.config/Code - OSS/Backups and ~/.config/Code - Insiders/Backups for the open source version and the Insiders version, respectively.
    – Marc.2377
    Jun 29, 2019 at 1:49
  • the opensource version folder might have changed: I found it at ~/.config/VSCodium/Backups
    – maxlath
    Oct 10, 2020 at 10:13
  • Found mines in ~/.config/Code/User/History
    – f.cipriani
    Feb 17 at 15:11
  • @f.cipriani this is for edit history of all files you edit there.
    – Alex
    Mar 6 at 13:14
22

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
3
  • 3
    awesome, ~/Library/Application\ Support/Code/Backups is the path
    – kisna
    Mar 12, 2021 at 1:09
  • As an example on OSX for Azure Studio (which is based on VS): ~/Library/Application Support/azuredatastudio/Backups/1623786046143/file/6be3cd5e7e4dd5b8f863e42c7ceef3e Jun 18, 2021 at 14:30
  • 1
    thank you so much! My vscode app kept opening an old file that I had deleted that was a 2gb+ sql file! It kept crashing and I was locked out of my code base until I deleted the backup! Jul 27, 2022 at 21:02
1

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
1

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.

0

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.

1
  • This is the same as the accepted answer
    – Burgi
    Jul 19, 2023 at 11:42
-2

Windows, Visual Studio 2019:

%localappdata%\Microsoft\VisualStudio\BackupFiles
1
  • 1
    The OP was specifically asking about VS Code rather than the full Visual Studio.
    – Burgi
    May 18, 2021 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .