In this VS code tutorial, we will discuss what is a visual studio workspace. How to create a workspace in vs code? Also, we will see how to add a folder to a workspace in visual studio code and how to Open and Close a workspace.
What is visual studio code workspace?
- A Visual Studio Code workspace can contain multiple files and folders. It allows customizing the settings and preferences of a workspace.
- A VS Code workspace contains one or more root folders with a configurations file (.code-workspace)
- .code-workspace is a JSON file that contains configuration information with the location of all root folders belonging to a workspace.
How to create a workspace in visual studio code
Now, let us see how to create a workspace in vs code.
Here, first I have created a few folders in my E drive. It looks like below:
Now Open the Visual Studio code, then go to File -> Open Folder…
Then select the Development folder like below:
Now click on File -> Save Workspace As…
Then you can provide a name for the workspace like below, click on Save.
Now, you can see in the VS code, the workspace will reflect like below:
If you will open the physical file location, you can see the file got created.
You can open the code workspace file in a notepad also. You can see it contains the path of the folder and also the settings section.
This is just a JSON file.
Anytime you can double click on the file to open the workspace in visual studio code.
This is how we can create a workspace in vs code.
How to add a folder to a workspace in visual studio code
Now, we will see how to add a folder to a workspace in code?
Open the workspace in vs code and then File -> Add folder to workspace…
Then you can select the folder which you want to add, and then your workspace will looks like below having both the folders.
This is how we can add a folder to a workspace in visual studio code.
How to Open and Close a Workspace in VS Code
Now we will see how to open and close a workspace in vs code.
You can directly open a workspace by double-clicking on the code-workspace file like below:
Or you can open vs code, go to File -> Open Workspace…
Then select the workspace file from the folder above and click on Open.
Similarly, to close a workspace from visual studio code, go to File -> Close workspace like below:
You may like the following vs code tutorials:
In this visual studio code tutorial, we learned:
- What is a visual studio code workspace?
- How to create a workspace in visual studio code
- How to add a folder to a workspace in visual studio code
- How to Open and Close a Workspace in VS Code
Bijay Kumar is a renowned software engineer, accomplished author, and distinguished Microsoft Most Valuable Professional (MVP) specializing in SharePoint. With a rich professional background spanning over 15 years, Bijay has established himself as an authority in the field of information technology. He possesses unparalleled expertise in multiple programming languages and technologies such as ASP.NET, ASP.NET MVC, C#.NET, and SharePoint, which has enabled him to develop innovative and cutting-edge solutions for clients across the globe. Read more…