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 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 few folders in my E drive. It looks like below:
Now Open 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 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 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:
- How to change background color in visual studio code
- Create a console application in visual studio code
- Connect-PnPOnline : The term ‘Connect-PnPOnline’ is not recognized as the name of a cmdlet, function, script file, or operable program
- tabulator js example
- How to debug PowerShell Script with Visual Studio Code
In this tutorial we learned:
- What is 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
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Out audiences are from the United States, Canada, United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a SharePoint MVP(8 times), check out My MVP Profile. I have also worked in companies like HP, TCS, KPIT, etc.