Visual Studio Code, like other IDEs, employs the concept of a ‘workspace.’ A workspace is simply a collection of Folders open in the IDE. For further information, see workplaces. In the most basic scenario, a workspace consists of only one folder: the project folder. So all we have to do now is create a folder.
The concept of a workspace allows VS Code to do the following:
- Set preferences that apply just to a single folder or folders and not to others.
- Task and debugger launch configurations that are only valid in that workspace are saved.
- The UI state associated with that workspace is saved and restored (for example, the files that are opened).
How to open a VS Code “workspace”
Using the File menu and picking one of the available folder entries for opening is the simplest approach to open a workspace. If you launch VS Code from a terminal, you may also pass the path to a folder as the first argument to the code command.
Only that workspace’s extensions can be enabled or disabled.
We don’t need to do anything other than open the folder in VS Code to make it a VS Code workspace. When we reopen a folder, VS Code will remember things like open files and editor layout, so the editor will be exactly where we left it when you reopen it. Other folder-specific configurations include workspace-specific settings (as opposed to global user settings), task definitions, and launch file debugging.
- Use menu File > Add Folder to Workspace.
- Browse to an existing new (empty) folder or simply create one from the dialog.
- Add a new file: main.c
- Implement the main function, then save it (CTRL+S)