16

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.

4 Answers 4

7

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

4
  • Is there a way to include this in the .code-workspace file?
    – HackXIt
    Commented Jun 17, 2019 at 13:35
  • @HackXIt No. These options seperate folders entirely, like using two users in Unix like OSes.
    – Biswapriyo
    Commented Jun 17, 2019 at 13:46
  • Alright. It definitly is a better way to install all extensions for one specific workspace then to disable them for all others. Thanks!
    – HackXIt
    Commented Jun 17, 2019 at 13:51
  • 1
    @HackXIt You can copy the "Normal" folders into "Angular" then configure the second one. So that you've not to do same thing twice.
    – Biswapriyo
    Commented Jun 17, 2019 at 13:56
25

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.
1
  • 3
    I've had to start doing this as well. It's odd that there are options Enable (Workspace) and Disable (Workspace), but no Install (Workspace) option? :/
    – Nermin
    Commented Mar 23, 2022 at 12:59
2

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

2

The April 2024 VS Code update now provides a clean way to accomplish this via the "local workspace extensions" feature. In order to use this feature, the unpackaged extension must be placed under the .vscode/extensions/ folder. Unfortunately, this option currently requires that you both build the extension yourself and manually update it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .