How do I back up my VS Code settings and list of installed extensions?

83

35

I've just been through the VS Code installation process twice. The initial install is quick and painless (as is the editor itself), but I have had to remember the list of extensions I installed and am installing new ones a great rate.

With Sublime Text, I'd just copy a settings file to another PC and could auto-install any workflow dependencies that way, but what is the approach with VS Code?

Can I just back up a JSON 'settings' file or similar so that I can easily re-create my working environment (complete with extensions)?

Astravagrant

Posted 2016-05-25T11:48:01.260

Reputation: 1 545

Just like other cross-platform editors, simply copy the .vscode directory to the new user environment's home directory. – JW0914 – 2020-02-07T13:17:36.677

Answers

68

I've submitted an answer for this on the main StackOverflow site - pasted below for context

I've need to do this myself a few times - especially when installing on another machine.

Depending on your platform VS Code looks for your extensions folder (.vscode/extensions) on one of the following paths:

  • Windows: %USERPROFILE%\.vscode\extensions
  • Mac: ~/.vscode/extensions
  • Linux: ~/.vscode/extensions

That should show you a list of the extensions

I've also had success using Visual Studio Code Settings Sync Extension to sync settings to GitHub gist

EDIT: In the lastest release of VSCode (May 2016) it is now possible to list the installed extension in the command line

code --list-extensions

MarkP

Posted 2016-05-25T11:48:01.260

Reputation: 796

Settings Sync extension worked like charm, just exported my settings from OS X to Linux Mint. – vikas027 – 2017-08-09T11:20:08.657

11I don't want to Sync! I want to backup! You did not properly answer the original question. – JesseNewman19 – 2017-12-08T01:51:45.897

11

The Settings Sync extension should do the trick, though the UX is so-so.

It syncs your settings to a GitHub Gist in JSON format. You’ll have to create a GitHub token. I suggest saving the token code in the token file name, as when you need to download your settings again later, it’s unlikely you’ll have the code handy (at least, that was my case).

Brandon

Posted 2016-05-25T11:48:01.260

Reputation: 881

If you know you will need your GitHub token for the Settings Sync extension, you can get it from the token key in the syncLocalSettings.json that is in your Code profile, in the same folder as settings.json. – Rory O'Kane – 2019-09-12T08:47:10.483

10

So as treehead's edit or MarkP's answer showed you can now list all extensions installed so the way to install that list of extensions would be to:

code --list-extensions >> vs_code_extensions_list.txt

Transfer the newly created file to the machine that you want to install those extensions to. On that machine you would:

cat vs_code_extensions_list.txt | xargs -n 1 code --install-extension

Which will then go through each extension in that file and install the extension.

If you want a clean install (AKA remove all existing extensions on that machine) you could run this before you install the new extensions (otherwise you will remove those new extensions too). BE CAREFUL as this will remove all extensions in VS Code:

code --list-extensions | xargs -n 1 code --uninstall-extension

NickTheSick

Posted 2016-05-25T11:48:01.260

Reputation: 101

Tried, got this error message: "xargs : The term 'xargs' is not recognized as the name of a cmdlet, function, script file, or operable program." ? – Nicholas Petersen – 2019-07-15T18:44:28.393

1@NicholasPetersen That's for Linux. On windows: get-content c:\exportedlist.txt | % { code --install-extension $_ } – Jason Clement – 2019-10-18T21:06:14.300

4

Here's the location of the VSCode settings:

Windows %APPDATA%\Code\User\settings.json
macOS $HOME/Library/Application Support/Code/User/settings.json
Linux $HOME/.config/Code/User/settings.json

It appears to only be storing modified settings, which is really nice (so you don't clobber up or screw with future versions).

You may also want /snippets/, in the same folder as settings.json.

And, of course, you can run code --list-extensions, as the other answers already mention.

Andrew

Posted 2016-05-25T11:48:01.260

Reputation: 175

1Your answer is the only one to cover backing up (not syncing) both extensions and settings. Thank you for an accurate answer. – Jimmy – 2020-01-25T15:20:47.320