126

I'd like to be able to sync my VS Code user settings (File > Preferences > User Settings) to the cloud somehow so I can easily share them between multiple installations, as in Windows 10 and Visual Studio.

Is there a supported way of doing this? Direct support in Code would be great, but otherwise being able to move my settings.json location to a Dropbox or OneDrive folder would work too.

I'm looking specifically for a way of doing this automatically and silently. Manually exporting/importing is too cumbersome and isn't what I'm looking for.


Update: this is now a built-in feature in VS Code.

Mark Whitaker
  • 8,465
  • 8
  • 44
  • 68
  • 2
    A very simple way would be if you use Google's Backup and Sync program and just add to backup your C:\Users\\[YOUR_USER]\AppData\Roaming\Code\User folder. – vinsa Jan 21 '18 at 01:21
  • Possible duplicate of [How to export settings of Visual Studio Code?](https://stackoverflow.com/questions/35368889/how-to-export-settings-of-visual-studio-code) – Shan Khan Nov 11 '18 at 21:09

10 Answers10

135

I have developed an extension that will sync all your Visual Studio Code Settings across multiple instances.

Key Features

  1. Use your GitHub account token.
  2. Easy to Upload and Download on one click.
  3. Saves all settings and snippets files.
  4. Upload Key : Shift + Alt + u
  5. Download Key : Shift + Alt + d
  6. Type Sync In Order to View all sync options

It Sync

  • Settings File
  • Keybinding File
  • Launch File
  • Snippets Folder
  • VSCode Extensions

Detail Documentation Source

VSCode - Settings Sync blog post

Download here : VS Code - Settings Sync - Extention

Gianfranco P.
  • 10,049
  • 6
  • 51
  • 68
Shan Khan
  • 9,667
  • 17
  • 61
  • 111
  • 1
    Thanks Shan Khan - this extension is quite useful - I have a set of virtual servers where I need to sync VS Code settings and key bindings between instances and this extension works exactly as advertised. – Bill_Stewart Sep 06 '16 at 21:02
  • Tried it but no success. When I activate it by Alt-Shift U, I get an error: extensionHost.ts:293[Extension Host] {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}A.logExtensionHostMessage @ extensionHost.ts:293 messageService.ts:126Error Logged In Console (Help menu > Toggle Developer Tools). You may open an issue using 'Sync : Open Issue' from advance setting command.e.doShow @ messageService.ts:126 – Robin Coe Jan 18 '17 at 21:05
  • because the token is not valid, try resetting the extension settings and add new generated token – Shan Khan Jan 20 '17 at 07:22
  • 4
    I'd love to accept this answer, but I tried the tool out and found it unreliable and buggy. Very simple scenario: VS Code installed on two machines, and I was trying to get both to auto-upload/download settings and extensions changes. I eventually gave up after failing to get it to work. So, great idea but needs more work. – Mark Whitaker Jul 20 '17 at 08:07
  • @MarkWhitaker u can post an issue in github with the exception its giving so we can discuss it further. – Shan Khan Jul 21 '17 at 05:53
  • There was no exception, it just didn't work. I'd change settings in one instance, close it down, open another instance: nothing synced. – Mark Whitaker Aug 25 '17 at 09:50
  • @MarkWhitaker Indeed. I tried just today and rather than syncing and merging my extensions / settings between two environments, it overwrote all of the above from the initial environment where I first installed the extension and forced the identical state into my other environments. It does not appear to be a proper syncing tool which actually merges differences and tries to reconcile them. The states should be merged, and where a conflict exists, the user should be prompted to address it. :( – Chiramisu Jun 23 '18 at 21:10
  • 2
    I have mixed feelings posting my settings to a (semi-)public Gist. Some extensions store sensitive data (such as database logins, SFTP logins) in their settings. Would it be hard to redirect storage to a "local" file instead, synchronized by an external tool like Syncthing or Resilio Sync? – korkman Jan 14 '19 at 18:41
  • 1
    @korkman for handling these situations, Settings Sync will allow to sync via local files and git repositories like gist in future updates. – Shan Khan Jan 15 '19 at 13:06
  • I totally agree with @korkman -- Shan Khan, is there likely to be any movement on this any time soon? – simon Jun 21 '19 at 23:12
  • Is there anyway to run this from a CLI? – ProfessorManhattan Apr 29 '20 at 14:09
21

You can make a hard link from the directory containing user settings to your sync directory of applications such as Dropbox or OneDrive.

For example, on windows, the user settings are located in %APPDATA%\Code\User, so you could type:

mklink /H /J X:\Your\Sync\Dir %APPDATA%\Code\User

on your computers with Visual Studio Code to achieve the synchronization.

Then, on another computer, you may delete the %APPDATA%\Code\User folder, and type:

mklink /H /J %APPDATA%\Code\User X:\Your\Sync\Dir

to retrieve the synchronized settings.

Mr. Ree
  • 871
  • 9
  • 20
  • Hi ! I don't understand why you would need to make a link FROM the sync directory TO the %appdata% folder. Move once for all your actual VS settings in the sync directory (DropBox, OneDrive, whatever...), then on every computer you want to sync the settings, delete `%APPDATA%\Code\User` and create the link by using `mklink /H /J %APPDATA%\Code\User X:\Your\Sync\Dir` – Michaël Polla Mar 26 '17 at 17:03
  • 2
    Because you will fail to create a link if the given name already exists, while the sync directory will be there once the settings have been downloaded. – Mr. Ree Mar 28 '17 at 02:53
  • This fails for network drives with the message `"Local NTFS volumes are required to complete the operation."` – Amit Beckenstein Jan 29 '20 at 12:37
12

In v1.48:

Preview features

Preview features are not ready for release but are functional enough to use. We welcome your early feedback while they are under development.

Settings Sync

Settings Sync is now available for preview in the stable release . Refer to the user guide for more information & FAQs.

Feature is now called Settings Sync also in the product. All of its references & settings are renamed to be aligned.

Also see "Manual merge" and syncing between Insiders and Stable at https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_48.md#settings-sync


In v1.45 it looks like you will be able to login to the built-in Settings Sync via github, see https://github.com/microsoft/vscode/issues/95160#event-3266867554 (Support GitHub logins in settings sync). And the v1.45 Release Notes.


In v1.43 as a preview feature (so in the Insiders' Build only) is settings sync. See https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_43.md#settings-sync

Settings Sync

We have been working the last couple of months to support synchronizing VS Code settings, extensions, and keyboard shortcuts across machines (popular feature request #2743). In this milestone, we are happy to announce that this feature is ready for preview from our next 1.44.0-insider release. You can now have your customizations synchronized in all your VS Code installs across all your machines. You can also bootstrap VS Code with your personal customizations on a fresh machine with minimal effort. Following video demonstrates this:

Supports detecting conflicts in settings and keybindings while synchronizing. Conflicts are shown using the diff editor with incoming (cloud) changes on the left side and local changes on the right side. You can resolve the conflicts by editing in the right side editor and merge the changes using the actions provided in the editor.

Supported Features

Currently Settings, Keyboard Shortcuts, Extensions, and the Display Language are synchronized but we are planning to add more. You can review our list of proposed Setting Sync features.

Machine settings (with machine or machine-overridable scopes) are not synchronized by default. You can also add or remove settings you want to this list from settings editor or using the setting sync.ignoredSettings.

Keyboard Shortcuts are synchronized per platform by default. If your keyboard shortcuts are platform agnostic then, you can synchronize them across platforms by disabling the setting sync.keybindingsPerPlatform.

All built-in and installed extensions are synchronized along with their global enablement state. You can skip synchronizing an extension, from extensions view or using the setting sync.ignoredExtensions.

Settings Sync activity can be monitored in the Log (Sync) output view. All local customizations are backed up for last 30 days (atleast 10) in the disk whenever they are changed during synchronization. You can use the command Sync: Open Local Backups Folder to go the backups location and retain your old customizations.

(and a few gifs at the release note link)

Note that is working through your Microsoft account, not github (until v1.45 - see top):

Settings Sync uses a Microsoft account to store your VS Code customizations for synchronization and therefore you would need an account to use this. Refer to the Settings Sync documentation for more information and help.

Also see https://github.com/microsoft/vscode-docs/blob/vnext/docs/editor/settings-sync.md for more on how to set up settings sync.


And a link to v1.44 info on Settings Sync: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_44.md#settings-sync

Mark
  • 143,421
  • 24
  • 428
  • 436
11

Aha, you can try my VSCode extension: Syncing.

Hoping you'll like it. :)


A Quick Guide

  1. Install Syncing:

  2. Get your own GitHub Personal Access Token:

    1. Login to your GitHub Settings page.

      login to settings page

    2. Select Personal access tokens tab and click Generate new token.

      generate new token

    3. Select gist and click Generate token.

      allow gist

    4. Copy and backup your token.

      copy and backup token

  3. Sync your settings:

    Syncing will ask for necessary information for the first time and save for later use.

    1. Upload:

      1. Type upload in VSCode Command Palette.

      2. Enter your GitHub Personal Access Token.

      3. Enter your Gist ID (or leave it blank to create automatically).

      4. Done!

      5. After uploading, you can find your settings and the corresponding Gist ID in your GitHub Gist.

        settings and gist

    2. Download:

      1. Type download in VSCode Command Palette.

      2. Enter your GitHub Personal Access Token (or leave it blank if you want to download from a public Gist)

      3. Enter your Gist ID (or a public Gist ID).

      4. Done!

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Nonoroazoro
  • 310
  • 5
  • 7
  • Hm. This doesn't seem to sync the extensions I have installed in the reference VS Code install. Am I missing something or is this functionality beyond the scope of this tool? – SeaDude Dec 26 '18 at 18:48
  • EDIT: I had to run `Syncing: Download Settings` 2x to get the Extensions to download. No biggie, just a heads up. Thanks for the killer tool! – SeaDude Dec 26 '18 at 18:56
  • 1
    I have mixed feelings posting my settings to a (semi-)public Gist. Some extensions store sensitive data (such as database logins, SFTP logins) in their settings. Would it be hard to redirect storage to a "local" file instead, synchronized by an external tool like Syncthing or Resilio Sync? – korkman Jan 14 '19 at 18:40
  • @korkman Exporting to local storage is not supported yet, but it could be better to support the file synchronization. – Nonoroazoro Jan 15 '19 at 03:16
6

I did this on my Mac by copying VS Code's settings.json to my iCloud drive for automatic backup, and then creating a symbolic link.

  1. Copy settings.json from VS code settings directory $HOME/Library/Application Support/Code/User/settings.json to your backup location
  2. Backup the old settings.json by renaming to settings-old.json
  3. In the terminal, cd to VS code setting dir: cd ~/Library/Application\ Support/Code/User/
  4. Create the symlink to your backed up file using command ln -sf path/to/backup/settings.json settings.json. Since I backed mine up to iCloud and renamed the file to vscode.settings.json, my command looked like this: ln -sf ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode.settings.json settings.json
  5. Check that you can open up user preferences in VS Code

To use the backup on a different Mac, just repeat steps 2-5.

I also did this for extensions...

cd ~/.vscode/
mkdir ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode/
cp -a extensions ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode
mv extensions extensions-old
ln -sf ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode/extensions extensions
Chris Feist
  • 1,678
  • 15
  • 17
  • @frankhommers It looks like this can be replicated using the Window's symlink command: [`mklink`](https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/). You can use DropBox, OneDrive, or another cloud service instead of iCloud drive – Chris Feist Apr 10 '19 at 16:28
5

Another way of doing it would be to soft link your files, which can also be stored in a repository on GitHub. For example, on Mac OS let's say you have a directory called ~/dev/dotfiles/vscode. Let's say there are two files in there called settings.json and keybindings.json. You could soft link these files with:

ln -s ~/dev/dotfiles/vscode/keybindings.json ~/Library/Application\ Support/Code/User/keybindings.json
ln -s ~/dev/dotfiles/vscode/settings.json ~/Library/Application\ Support/Code/User/settings.json

If you are using Windows or Linux the path to the respective settings directories can be found at https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations

David
  • 4,191
  • 2
  • 31
  • 40
4

I place my settings.json in a configuration file that I sync with git (though Dropbox would also work) and use a Python script to symlink it to the correct location for each platform so updating it from the settings menu syncs across my machines. Creating symlinks requires admin privileges on Windows.

import os
import platform

# Find the settings file in the same directory as this script
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
VS_SETTINGS_SRC_PATH = os.path.join(SCRIPT_DIR, 'settings.json')

# https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations
if platform.system() == 'Windows':
    VS_SETTINGS_DST_PATH = os.path.expandvars(r"%APPDATA%\Code\User\settings.json")
elif platform.system() == "Darwin":
    VS_SETTINGS_DST_PATH = os.path.expandvars(r"$HOME/Library/Application Support/Code/User/settings.json")
elif platform.system() == "Linux":
    raise NotImplementedError()
else:
    raise NotImplementedError()

# On Windows, there might be a symlink pointing to a different file
# Always remove symlinks
if os.path.islink(VS_SETTINGS_DST_PATH):
    os.remove(VS_SETTINGS_DST_PATH)

choice = input('symlink %r -> %r ? (y/n) ' % (VS_SETTINGS_SRC_PATH, VS_SETTINGS_DST_PATH))
if choice == 'y':
    os.symlink(VS_SETTINGS_SRC_PATH, VS_SETTINGS_DST_PATH)
    print('Done')
else:
    print('aborted')
Ben
  • 5,952
  • 4
  • 33
  • 44
4

This is finally a built-in feature: see Settings Sync in Visual Studio Code.

Mark Whitaker
  • 8,465
  • 8
  • 44
  • 68
  • 2
    Still in preview though – Frank Fu May 11 '20 at 03:23
  • @FrankFu Well, but this is a big feature, and they're making progress: you're able to sync to microsoft/github account, and there's a proposed api for account login etc. (which will be useful to other extensions such us github btw) – Chayim Friedman Jul 11 '20 at 22:22
  • @ChayimFriedman, oh 100%, in no way was my intention to complain. I felt like it needed to be cleared up to avoid giving people false hope since the original unedited answer did not say otherwise. – Frank Fu Jul 12 '20 at 12:42
  • In 1.48 it is stable now: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_48.md#settings-sync – deoomen Aug 17 '20 at 13:49
3

User Settings

There is currently no automatic synchronization for user settings available in Visual Studio Code. On Windows the user settings are located in %APPDATA%\Code\User\settings.json. You could save a copy of that file on OneDrive or Dropbox and move it on all your machines to the user settings folder. But this still includes manual steps on each machine every time you change the configuration.

You can suggest an automatic synchronization of settings here: https://visualstudio.uservoice.com/forums/293070-visual-studio-code

Workspace Settings

Add the .vscode folder of your workspace to the version control system (Git/SVN etc). When you checkout the code from the repository you will automatically get the VS Code workspace settings.

Mark Whitaker
  • 8,465
  • 8
  • 44
  • 68
Wosi
  • 41,986
  • 17
  • 75
  • 82
-8

Use workspace-settings instead of user-settings.

ColacX
  • 3,928
  • 6
  • 34
  • 36
  • Not a constructive suggestion as workspace settings do not sync across project or systems. – Itanex Aug 03 '18 at 06:08
  • 2
    Giving @ColacX the benefit of the doubt, I'm assuming what was meant was that if you use workspace-settings, you can save them in git/svn/etc, which _does_ in fact sync them in a sense. – Joshua Sleeper Aug 14 '18 at 21:08