For example, Visual Studio Code talks about applying settings at the user level vs the workspace level.
On the one hand,
- it could refer to a project directory that you have opened; or
- it could refer to everything you have opened in a particular window.
The page referenced above says
"Workspace: These settings are stored inside your workspace in a .vscode folder and only apply when the workspace is opened."
ベストアンサー1
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.
本当に必要な場合は、ルート フォルダーを 1 つだけ含むファイルを作成できます.code-workspace
。そうすれば、プロジェクト フォルダーを直接開くことも、ワークスペース ファイルを開くこともできます。ただし、これがなぜ有益なのかはわかりません。
ファイルを作成するにはどうすればいいですか.code-workspace
?
メニューの「ファイル」 → 「ワークスペースに名前を付けて保存...」に移動します。
ワークスペースにルート フォルダーを追加するにはどうすればよいですか?
メニューの「ファイル」 → 「ワークスペースにフォルダーを追加...」に移動します。
ファイルによって定義されたワークスペースを開くにはどうすればよいですか.code-workspace
?
メニューの「ファイル」 → 「ワークスペースを開く...」に移動します。
または、.code-workspace
ファイルをダブルクリックします。Visual Studio Code は実際のファイルを開きません。代わりに、そのファイルを読み取り、そのワークスペースに属するフォルダーを開きます。
実際の.code-workspace
ファイルを表示するにはどうすればいいですか?
メニューの「ファイル」 → 「開く...」に移動し、対象.code-workspace
ファイルを選択します。
または、そのファイルに関連付けられたワークスペースを開きます。次に、コマンドパレットをクリックし、「ワークスペース: ワークスペース構成ファイルを開く」コマンドを検索して選択します。