Workspace file vs .vscode files - where do my project settings actually go?
What's the point of user settings?
[Feature] Local Workspace settings
VS Code: What is the difference in settings between User and Workspace - Stack Overflow
Videos
Totally VSCode noob here... but in sublime, the project file is what holds all the project specific settings. In VSCode it looks like there are potentially 2 places for workspace settings: The workspace file, and settings.json (potentially others) inside the .vscode folder.
What actually goes where? On my work computer, I added some filename patterns to exclude from the side bar and vscode created a settings.json file inside a new .vscode folder. On my personal computer I tried the same thing and vscode just added those settings to my workspace file.
Everytime I open a new workspace, its settings are set to some default values and I have to manually copy over my user settings to the workspace settings, every single time. I'd assumed that vscode would, initially, populate a new workspace's settings with my user settings that I carefully crafted, but no...
Do you know of a way to edit the default values used to initialize new workspaces with? Or perhaps a way to automate copying over the user settings file for newly created workspaces? Many thx!
What is a workspace?
A project that consists of one or more root folders, along with all of the Visual Studio Code configurations that belong to that project. These configurations include:
- settings that should be applied when that project is open
- recommended extensions for the project (useful when sharing the configuration files with colleagues)
- project-specific debugging configurations
Why is a workspace so confusing?
Visual Studio Code does not use the term consistently across the UI (I've opened a GitHub issue to address this). Sometimes it refers to a workspace as described above, and other times it refers to a workspace as a project that is specifically associated with a .code-workspace file.
A good example being the recent files widget. Notice in the linked screenshot that all projects are grouped under the same "workspaces" heading, which would indicate that everything there is a workspace. But then projects with a .code-workspace file are given a "Workspace" suffix, contradicting the heading and indicating that only those files are actually workspaces.
What is a .code-workspace file?
It is a JSON file with comments that stores all of the configuration data mentioned above, in addition to the location of all root folders belonging to a workspace.
Do I need a .code-workspace file?
Only if you're creating a multi-root workspace, in which case you'll have a single .code-workspace file that automatically restores all of the workspace settings, in addition to all of the root folders that you want to be displayed in the Explorer.
What about single folder projects?
Everything is automated.
When you open a folder in Visual Studio Code and start making modifications to the editor that are specifically related to the project you're currently working on, Visual Studio Code automatically creates a .vscode folder and stores it in the root of the project folder that you're working on. This .vscode folder has files that store the changes you made.
For example, if you change Visual Studio Code settings that you want to apply only to your current project, Visual Studio Code creates a settings.json file with those updates, and that file is stored in the .vscode folder.
You can create a .code-workspace file that includes just a single root folder if you really want to. You'd then be able to either open the project folder directly, or open the workspace file. But I can't think of any reason why this would be beneficial.
How do I create a .code-workspace file?
Go to menu File → Save Workspace As...
How do I add root folders to a workspace?
Go to menu File → Add Folder to Workspace....
How do I open a workspace that is defined by a .code-workspace file?
Go to menu File → Open Workspace....
Alternatively, double click the .code-workspace file. Visual Studio Code won't open the actual file. Instead, it will read that file and open the folders that belong to that workspace.
How do I view the actual .code-workspace file?
Go to menu File → Open... and select the target .code-workspace file.
Alternatively, open the workspace associated with that file. Then open the command palette, search for, and select the Workspaces: Open Workspace Configuration File command.
You can save settings at the workspace level and you can open multiple folders in a workspace. If you want to do either of those things, use a workspace, otherwise, just open a folder.
A Visual Studio Code workspace is a list of a project's folders and files. A workspace can contain multiple folders. You can customize the settings and preferences of a workspace.