Is there a way to install vs-code extensions only inside the workspace?

I just started a course in Angular and while working on that I figured I'd also install basic extensions that make working with this web-development workspace easier.

Since I use Settings Sync those extensions immediatly got uploaded to my settings gist. The problem however is that I don't want these web-development settings/extensions on all my other workspaces.

Disabling the added extensions inside all other workspace is very time consuming, so I wondered if it is possible to install specific extensions only inside a workspace?

Inside the local settings-sync there is the option to ignore extensions, but this makes only sense after installing because when installing Extension-Packs, that come with multiple extensions, it is not very clear from the beginning what the extension names are. It even can be tedious to do this, because some extensions also alter the settings.json, which then gets uploaded even though those settings shouldn't be inside the workspaces without those extensions.

In other words it just scales absurdly and installing for only this workspace would make sense in my opinion.

The question is about a simple way to install extension for just this workspace as they are only required in there.


Solution 1:

Extension installations can be separated using different directory to store extensions. As VSCode is built with Electron framework (NodeJS + Chromium V8 engine) the command line options are same in all Electron based Apps and also in Chromium. Here we use these two command line options. According to VSCode Docs:

 Options                 Description

--extensions-dir <dir>   Set the root path for extensions.
--user-data-dir  <dir>    Specifies the directory that user data is kept in, useful when running as root.

Using these two command line options we can separate the user data (settings, preferences, opened files etc.) and extensions installation folder. If the folders are not present it will be automatically created after running the following commands. The folder paths here are for examples. Change these path as you want.

  • For Windows:

    • Normal workspace:

    code.exe --extensions-dir "D:\CodeProfile\Normal\exts" --user-data-dir "D:\CodeProfile\Normal\data"

    • Angular workspace:

    code.exe --extensions-dir "D:\CodeProfile\Angular\exts" --user-data-dir "D:\CodeProfile\Angular\data"

  • For UNIX-like OS:

    • Normal workspace:

    code --extensions-dir "~/CodeProfile/Normal/exts" --user-data-dir "~/CodeProfile/Normal/data"

    • Angular workspace:

    code --extensions-dir "~/CodeProfile/Angular/exts" --user-data-dir "~/CodeProfile/Angular/data"

Optionally, create a desktop shortcuts with these command line options to skip using terminals or consoles. Also you may have to configure the Settings Sync extensions to use these path accordingly.

Further Readings

  • Visual Sudio Code: Command Line Interface (CLI)
  • List of Chromium Command Line Switches (by Peter Beverloo)

Solution 2:

As of June 2020 it looks like you can globally disable an extension and then explicitly enable it for a workspace. I've started doing this across JS/TS, Rails, Java, and Scala workspaces and it seems to work well.

To do this:

  1. On the Extensions sidebar, select the extension then select the 'Disable' button. This will disable the extension for all workspace.
  2. Then select "Enable (workspace)" to enable it for the current workspace.

Solution 3:

I have been looking for a way to do this for a long time and I finally found an extension that makes it possible! The extension I found allows you to create and manage profiles for VsCode, in each profile you can make a completely ISOLATED configuration, configure font, size, spacing, EXTENSIONS and etc. For example, I have some profiles set up, when opening a Web Php project I can switch to the "Web Php" profile, when doing college activities in C, I switch to the "C" profile.

https://github.com/aaronpowell/vscode-profile-switcher#extensions