Where are Untitled Tabs in VSCode Saved on a Windows System?

Ever wonder how VSCode (Visual Studio Code) maintains those untitled tabs between sessions? They’re stored as files underneath your user’s profile in appdata on Windows based systems as shown in the following example.

The previous command could be piped to Get-Content to view the contents of all of code in the open untitled tabs of VSCode. You could also use Select-String to find something specific. I can see that three of my open tabs contain ‘mikefrobbins’.

Concerned about losing information contained in your untitled tabs? You should probably save them, but you also have the option of backing up all of your untitled tabs using the following PowerShell one-liner.

Thoughts, questions, comments? Please post them as a comment to this blog article.

µ

2 Comments

  1. Jaap Brasser

    Cool stuff Mike, I used to have email to OneNote setup for my ISE untitled tabs. Once a week I would run this, it would grab all code from all untitled tabs and send it to a specific OneNote workbook. Probably could do the same for VScode tabs as well!

    Reply
  2. REOScotte

    I use this to keep them backed up in OneDrive. I do something similar with Notepad++. Might cause some excessive churn on the sync agent, but it hasn’t been a problem for me.

    $oneDrivePath = “$env:USERPROFILE\OneDrive\VSCodeBackup”
    $vsCodeBackup = “$env:APPDATA\Code\Backups”
    Move-Item -Path $vsCodeBackup -Destination $oneDrivePath

    # Need to be admin to do it the powershell way, but that screws up the dynamic paths
    # New-Item -Path $vsCodeBackup -ItemType SymbolicLink -Value $oneDrivePath

    # so, resorting to good ole cmd.exe
    cmd.exe @(‘/c’, ‘mklink’, ,’/D’, $vsCodeBackup, $oneDrivePath)

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: