snowfrogdev
snowfrogdev

Reputation: 6873

How to set which extensions are enabled when opening a new folder or workspace?

I have a great many extensions, and on any given project, I find myself using maybe a third of all of them (If I'm working on a Python project, I don't really need JavaScript-related extensions now do I?). The problem is that right now VS Code loads and enables every single extension installed at the start of each new project. I find it a pain to then have to manually go and disable all the extensions I won't be needing for the project.

Is there a way to setup VS Code to only enable certain extensions when opening a new folder / workspace? I couldn't find anything in the docs on that subject and when looking at the extension section of the preferences I couldn't find such a functionality.

Upvotes: 31

Views: 13780

Answers (3)

starball
starball

Reputation: 52324

The problem is that right now VS Code loads and enables every single extension installed at the start of each new project. I find it a pain to then have to manually go and disable all the extensions I won't be needing for the project.

For new workspaces, VS Code loads by default all extensions that have been enabled on a global (non-per-workspace) basis. So I just take the opposite approach as you: I leave most of my extensions disabled by default- except those that I expect to use in all my workspaces, and then when I create a new workspace, I just enable the few additional ones that I want enabled for that workspace. I usually also make use of .vscode/extensions.json for extensions that I'd recommend collaborators to use for the project.

Note that if you don't expect to actually use an extension for all your projects/workspaces but still leave it globally enabled, there's a chance that (depending on context) it might still not use any of your system resources (CPU, memory, etc.) because of activation events. Extensions need to say what events cause them to activate. If none of those events occur during a session of VS Code being open, then it will be as if that extension was disabled.

Upvotes: 3

snowfrogdev
snowfrogdev

Reputation: 6873

As of Feb 2023, it is now possible to create different Profiles in VS Code.

A Profile can include extensions, settings, keyboard shortcuts, UI state, tasks, and user snippets. You can customize VS Code for different development scenarios like data science, documentation writing, or for multiple programming languages like Python or Java. If you have different VS Code setups based on workflow such as "Work" or "Demo", you can also save those as different profiles. You can open multiple workspaces (folders) with different profiles applied simultaneously.

The following image demonstrates a folder opened with a Work profile that is customized for a work setup. a folder opened with a Work profile

Upvotes: 40

snowfrogdev
snowfrogdev

Reputation: 6873

To my knowledge, the best you can do is use the Enable, Enable (Workspace) and Disable, Disable (Workspace) options. Here is how ended up doing this:

  1. Open a new workspace / folder.
  2. Disable all extensions using Disable.
  3. Enable all extension that you want to have enabled in every new project with Enable.
  4. Enable extensions that you only want to use in this particular workspace / folder with Enable (Workspace)

From then on, when you open a new workspace, only the "default" extensions should be enabled. If ever you want to disable one of these "default" extensions in a particular workspace but still want it to be a "default" extension, make sure to use the Disable (Workspace) option.

Upvotes: 14

Related Questions