Post

Syncing and configuring profiles in VS Code Revisited

Introduction

For a while now, I have been using profiles in VS Code. While I have been using this for ~2 years, I wrote something about it last year: Syncing and configuring profiles in VS Code. While this method has worked reasonably well for me, it was fairly finicky to setup and maintain because of the way the syncing to Github Gists was working. This meant adding profiles and settings could sometimes lead to profiles getting messed up.

One of the main extensions you needed to make this work was Settings Sync by Shan Khan. While it was already clear it was no longer actively maintained, recently I noticed that it is now showing up as ‘deprecated’ in VS Code.

Considering the effort to maintain it and the deprecation of it’s main driver, I needed to find a better solution, that would still allow me to easily swap between extensions and/or settings used for a specific profile. Luckily, after some reading up, I found that the VS Code team has been working hard of adding a native option. While still in preview, so far it seems to do everything I need, including support for Settings Sync (the native option, that is).

Installation

Installation is easy. From the settings enable the (preview) option: experimental settingsProfiles

I got confused by the ‘Not Synced’ part. Initially I interpreted this as that the settings profiles would not be synced anywhere. However, the only thing this means is that the experimental setting itself is not synced anywhere. More on this later.

Of course the alternative is to just directly add the setting to the settings.json:

1
2
3
{
   "workbench.experimental.settingsProfiles.enabled": true
}

After changing the setting, you will need to restart VS Code before you can continue

Setting up profiles

Also setting up new profiles is easy. After restarting VS code you will notice that a new icon has appeared in the left bottom of the Activity Bar:

activity bar

Creating a new profile can be done by simply clicking the new icon and choosing ‘Create’:

create profile

You can choose to create a new, empty profile or copy an existing profile:

select create option

Once the profile is created, you can then add an remove extensions to fit your profile as you see fit.

Eventhough you ‘delete’ the extension from a profile, VS Code will keep the extension downloaded, until there is no other profile using that extension anymore. While you appear to delete the extension, you are really only disabling it for this profile. This means that VS Code will not redownload extensions or remove them from disk when you swap profiles.

When you open Settings in VS Code most of the settings you set through the UI will end up in the settings.json for the active profile. However, some settings can only be set at the application level. These will end up in the settings.json for the Default profile. For instance the preview option that was enabled to be able to use profiles, Workspace Trust state, etc.

When you choose to open settings.json, you get the option to choose between user settings and the current profile settings, unless the Default profile is active, then they are both one and the same:

select settings.json

If you open the User Settings you will see that most settings are greyed out because they are not in use (again, unless you are in the default profile!). The Current Profile Settings will take you to the settings.json which is actually used for the active profile.

Switching profiles can be done in the Acitivy Bar at the same place:

select profiles

Syncing the settings and profiles between devices

In order to use the same settings and profiles on multiple devices, all you need to do is to setup Settings Sync, like described in the VS Code documentation: settings sync

I have only tested this from a first time setup perspective, that is: I created the new profiles on one machine and setup Settings Sync. Next I moved to the next machine and followed the settings here, allowing it to overwrite the local settings for this machine. So if you do not want to lose the local settings, you may need to change things!

On a second device, the first time you active Settings Sync to retrieve you settings, two things are important:

  1. Because your settings on this device are likely different from the settings that you downloaded through Settings Sync, you will get a warning that there is a conflict. In my case I just overwrote the local settings for the remote ones:

settings sync conflict

  1. While VS Code will download all your settings and profiles, as we noticed in the Installation part, the preview setting to enable settingsProfiles itself is not copied over. So we first need to active this setting again to get access to the profiles.

When you change profiles: if the extensions for this profile are not yet locally available, VS Code will download them and make them available. Depending on ‘stuff’ this may take a few minutes. During this time nothing appears to be happening, but give it a moment and your extensions should show up.

Sources

This post is licensed under CC BY 4.0 by the author.