Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have multiple platform-specific workspace settings.json files? Is it possible?

Is there a way in Microsoft VS Code to create two files for settings.json (different names or different subfolder) and switch between them?

Background: We use the Java Extension in VS Code. Our source code repository contains the settings for a Java project in a Unix environment. In specific cases we want to run the code in Windows environment and need a different settings.json.

like image 280
user2194358 Avatar asked Oct 20 '25 05:10

user2194358


1 Answers

Is there a way in Microsoft VS Code to create two files for settings.json (different names or different subfolder) and switch between them?

Not by default- no.

You can wait for this feature-request gets implemented (though you might be waiting a while): Allow to scope settings by platform #5595. You can show your support for the issue ticket by giving a thumbs up reaction to the issue. But please don't make a "me too" comment. "me too" comments generally come off as annoying to repo maintainers because they clutter up discussion and don't contribute anything of significant value.

In the meantime, you could create a script to do so with your technology of choice and write a VS Code task to run the script, but that sounds like a footgun for accidental thrashy git changes. I'd instead suggest writing two template files named something like .vscode/settings.unix.json and .vscode/settings.windows.json and committing those to version control, but putting .vscode/settings.json in the gitignore.

Certain other settings already have mechanisms to allow you have different values for different platforms: terminal profile definitions, and keybindings. But those are more user settings and not workspace settings.

You may also find the Profiles feature useful.

like image 176
starball Avatar answered Oct 22 '25 04:10

starball