Is it possible to use several different profiles with settings in vscode so that each profile has its own set of installed and enabled settings and each profile has its own extension settings?

Suppose I need an extension for working with github in one of the profiles, and a custom TFS plugin in the other, in the first one I need plugins for working with bootstrap, vue, in the other it is not needed.

I tried to search in the built-in help and google - I did not find that this is possible out of the box. Or is it possible?

  • 2
    workspace is not the same? - Grundy
  • As an option, you can write a console application that renames the .vscode folder to .vscode1, and .vscode2 to .vscode and vice versa - Alexey Obukhov at 1:59 pm
  • @Grundy Judging by the description - what you need. I'll try on the weekend, but in general - you would write in the answers. - AK
  • one
    @AK, the answer is not enough :-) and I didn’t try it myself, so I only heard with the edge of my ear, so the link is :-) how you try - add an answer with a detailed description - Grundy
  • one
    @Grundy Reached hands to understand - designed the answer. - AK

1 answer 1

So, the solution based on workspace, which @Grundy advised in the comments turned out to be very working.

The answer was run-in on windows, maybe I will repeat all the same actions on a virtual machine with debian later and add in response versions of hotkeys for nix-systems.

So, we go to the documentation and watch the introduction to the materiel. Settings are stored in two different places:

  • global settings that apply to all vscode instances running in any folder. Stored in %APPDATA%\Code\User\settings.json
  • settings for workspace (specific open folder), applied to vscode instances running in that particular folder. Stored in a file .\vscode\settings.json

I tested it on a simple setting "The default end of line character.":

 { "files.eol": "\n" } 

It is checked quickly and easily: created a new file and you look in the status line, it has type LF or CRLF.

This was a preliminary part. The second part is how to enable and disable extensions depending on the "profile". Here it is good to familiarize with one more link - discussion on the githabe of the on / off feature of the extension through the config.

It can be seen that an intuitive option was offered to store in .vscode / settings.json something like:

 { "extensions.enabled": ["ms-vscode.csharp", ...enabled], "extensions.disabled": [/*whatever extensions wanted to be*/...disabled], } 

But in the end, the developers did a little differently: it is not stored in the .vscode / settings.json config file, so it is impossible to upload the settings file to the folder :( but you can click the mouse.

enter image description here

What will need to be done. Suppose we have a Vetur extension and we decide that we basically work in vscode with c # code and sometimes (read it - much less often) we have to open projects vue.js. Then we take and globally turn off the Vetur extension, and then go into all our frontend projects and for them turn on the extension back, but already locally, for a specific workspace.

All these parameters are stored - but not in the .vscode folder, but in the %APPDATA%\Roaming\Code\User\workspaceStorage\ folder:

enter image description here

Where the path to the folder is written in the workspace.json file:

 { "folder": "file:///c%3A/git/github.com/user/prog/frontend" } 

, and the specific workspace parameters are stored in sqlite files.

So copying the settings from some other workspace becomes a bit more difficult: the main difficulty is to find the folders, I personally have about fifty worspaces due to watching a lot of projects on the githabe. But in general, there are no problems: I created test1 and test2 folders on the disk with different extension settings, and then just closed vscode and copied the state.vscdb file from folder to folder - and the settings on the next opening were the same as in another workspace .

So if you suddenly have to keep very different settings for formatters / linter and similar extensions, then in principle you can simply copy the settings from another project.