Open multiple Projects/Folders in Visual Studio Code - visual-studio-code

How do I open multiple projects/folders in a single Visual Studio Code instance, and open multiple files in single view? Does it has any option for future change request?

Not sure why the simplest solution is not mentioned. You can simply do File>New Window and open the other project in the new window.

Update
This is now available out of the box as of October 2017. From the blog post:
This was our #1 feature request - it's been a while coming but it's here now.
The complete documentation is here.
You can work with multiple project folders in Visual Studio Code with multi-root workspaces. This can be very helpful when you are working on several related projects at one time. For example, you might have a repository with a product's documentation which you like to keep current when you update the product source code.
Original answer
Currently the Insider channel of VSCode gives us this out of the box.
Read more from the blog post.

Update
As mentioned in several other answers here, this 'accepted' answer is outdated and is no longer correct. VS Code now has the concept of a 'workspace' which lets you add several 'root' folders to VS Code in the same window.
For instance, when working on a project in one folder that utilizes shared code held in a different folder, you can now open both the project folder and the shared folder in the same window.
To do this you use the Add folder to Workspace... command. VS Code then saves this configuration in a new file with a .code-workspace extension. If you double-click that file, VS Code will re-open with both folders present.
Original Accepted Answer (Outdated)
As described in The Basics of Visual Studio Code article:
"VSCode is file and folder based - you can get started immediately by opening a file or folder in VSCode."
This means the concept of solution and project files, like the .sln and .csproj, have no real function in VSCode other than that it uses these only to target and identify which language to support for Intellisense and such.
Simply put, the folder you open is the root you work with. But of course there is nothing from stopping you to open multiple windows.
As for the request features options, navigate to Help > Request Features which will redirect you to the UserVoice page of VSCode.

Support for multi-root workspaces is now enabled by default in the latest stable release [November 2017 release].
The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder.

If you are using unix like OS, you can create a soft link to your target folder.
E.g. I want to see golang source while I am using VSCode. So, I create a soft link to go/src under my project folder.
ln -s /usr/local/go/src gosrc
Hope this helps!
Update: 11/28, 2017
Multi Root Workspaces[0] landed in the stable build, finally.
https://code.visualstudio.com/updates/v1_18#_support-for-multi-root-workspaces
[0] https://github.com/Microsoft/vscode/issues/396

You can open any folder, so if your projects are in the same tree, just open the folder beneath them.
Otherwise you can open 2 instances of Code as another option

On Windows it's possible to use mklink to create directory symbolic links to the needed folders. Then keep them together in a folder, and VSCode will list the content of these.
c:\>mklink /D c:\dev\MyWork\scripts c:\ProjA\scripts
symbolic link created for c:\dev\MyWork\scripts <<===>> c:\ProjA\scripts
c:\>mklink /D c:\dev\MyWork\styles c:\ProjB\styles
symbolic link created for c:\dev\MyWork\styles <<===>> c:\dev\ProjB\styles
This is very similar to #NeilShen's idea, I guess.

Multiple Folders in VS
Click ->File ->Add Folder to Workplace.
Step 1.
Choose which project to work ->Add(press)
Step 2.

October 2017 (version 1.18):
Support for multi-root workspaces is now enabled by default in the Stable release: https://code.visualstudio.com/updates/v1_18#_support-for-multi-root-workspaces
Now we can open multiple folders in one instance, Visual studio code has named as Workspace ("Area de Trabajo"). Take a look at the images, it´s very simple.

Or you can just select multiple folders and then click open.
Go to File> Open Folder, then select multiple folders you want to open and click Select Folder

Just put your projects in the same folder and simply open that folder in vscode.
Now your projects will appear like:
GROUP OF PROJECTS
PROJECT 1
Contents
Contents
PROJECT 2
Contents
Contents

It's not possible to open a new instance of Visual Studio Code normally, neither it works if you open the new one as Administrator.
Solution: simply right click on VS Code .exe file, and click "New Window"
you can open as many new windows as you want. :)

You can install the Open Folder Context Menus for VS Code extension from Chris Dias
https://marketplace.visualstudio.com/items?itemName=chrisdias.vscode-opennewinstance
Restart Visual Studio Code
Right click a folder and select "Open New Workbench Here"
Open New Workbench Here

You can open up to 3 files in the same view by pressing [CTRL] + [^]

What I suggest for now is to create symlinks in a folder, since VSCode isn't supporting that feature.
First, make a folder called whatever you'd like it to be.
$ mkdir random_project_folder
$ cd random_project_folder
$ ln -s /path/to/folder1/you/want/to/open folder1
$ ln -s /path/to/folder2/you/want/to/open folder2
$ ln -s /path/to/folder3/you/want/to/open folder3
$ code .
And you'll see your folders in the same VSCode window.

you can create a workspace and put folders in that :
File > save workspace as
and drag and drop your folders in saved workspace

You can use this extension known as Project Manager
In this the projects are saved in a file projects.json, just save the project and by pressing Shift + Alt + P you can see the list of all your saved projects, from there you can easily switch your projects.

To run one project at a time in same solution
Open Solution explorer window -> Open Solution for Project -> Right click on it -> Select Properties from drop down list (Alt+Enter)-> Common Properties -> select Startup Project you will see "current selection,single selection and multiple selection from that select "Current Selection" this will help you to run one project at a time in same solution workspace having different coding.

You can simply add folders (as many you want) in your workspace as shown in this image:
Image
And use them unhesitatingly.

Related

Visual Studio Code has imported all folders associated with primary user of laptop,

I recently made VScode my primary IDE and it has since imported ALL of the folders associated with the primary user of my laptop. So folders associated with Dropbox, Applications, Creative Cloud, etc..etc.. are now showing up in the Explorer, under my name.
How do I remove these folders so that I can choose which folders I would like to open for my coding projects?
I can't find answers to this anywhere.
I've included a screenshot so that you can see what I am talking about.
Thank you in advance for any help you can offer.
enter image description here
vs code can be opened from a directory. it show all directory and file in pwd.
to open vs code in a directory you can execute code <path/to/where/you/want> in your terminal
As I understood, you are concerned that VSCode is showing all the folders you have when you open it up.
Let me clarify things for you:
Vscode is not an IDE, it's an advanced text editor.
Vscode does not import any files anywhere. It just works as a file browser;
it lists the files and folders of the folder that was opened in.
In your case, I think when you open up VScode, it's showing you the content of the /home directory (you are using linux or mac). If you want to open a specific folder, go to "Files" and then "Open Folder" and select the folder you want to open.

How can I cleanly remove Workspaces in Visual Studio Code?

I'm on a MAC and remove workspaces with the terminal in the folder ~/Library/Application Support/Code/User/workspaceStorage, but i don't think it's the clean way.
Can someone explain me how I can remove cleanly a workspace and all its files from my mac?
I miss this feature. I can add many workspaces, but where is the "delete button"?
I use Visual Studio Code V.1.28.2 on macOS Mojave 10.14.
You can use the command palette:
Menu: View > Command Palette... (or F1)
Search: "Workspaces: Remove Folder from Workspace..." and select the folder you want to remove.
Hope this may help you
Visual Studio Code 1.32.3. Windows 10.
Here's the answer from the Twitter account of Visual studio code:
You have just to go to the Explorer section and remove any folder or file in it see the image below:
right click in the workspace you'd like to remove and select the "Remove Folder from Workspace" item; the name of the workspace will become: "NO FOLDER OPENED" that is the one you'll get when you installed the very first time Visual Studio Code.
If none of the above solutions works ...you can go to file -> close folder.
It will close the workspace folder and you can add any new folder to the explorer, like the first time you install visual code
find workspace.json, it will be inside the workspace you had created workspaces->[unique number]->workspace.json . you can edit the workspace directories in it.
The only other relevant answer is this .
The Workspaces is stored at %userprofile%\AppData\Roaming\Code\User\workspaceStorage (Windows) , none of the mentioned actions will delete them .
There also can be a .code-workspace Workspace File or "Workspace Config", which can be moved anywhere . And .vscode Workspace Folder/-s in the folder/-s which was added to the workspace .
Deleting all existing of these 3, and the relevant items from : %userprofile%\AppData\Roaming\Code\storage.json and all %userprofile%\AppData\Roaming\logs<< .. >> . Will be a workspace deletion .
It seems that workspaces are either open or closed, you can close them from the main menu. To cleanly delete a workspace, just remove the workspace file from disk also.

can't add workspace in visual studio code

Just started with Visual Studio Code. I need to add more workspaces after the original one.
I tried googling the docs but there is no reference.
How do I add more workspaces?
As AitlioA said, in the same workspace is not possible.
If you want to create more workspaces:
Add folder in the same window: File > Add Folder to Workspace
Repeat many time as you want.
Save your workspace: File > Save Workspace As...
It will save your workspaces including all your folders. Next time, just select
File > Open workspace
Check the documentation: Multi root workspaces
Do you want to open multiple workspaces in the same window? This isn't possible.
See this issue.

What is a 'workspace' in Visual Studio Code?

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."
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.
A workspace is just a text file with a (.code-workspace) extension. You can look at it by opening it with a text editor. I too was frustrated by the idea of a workspace and how it is implemented in Visual Studio Code. I found a method that suits me.
Start with a single "project" folder.
Open Visual Studio Code and close any open workspaces or files or folders. You should see only "OPEN EDITORS" and "NO FOLDER OPENED" in the EXPLORER.
From the menu bar → File → Open Folder.... Navigate to where you want to put your folder and right click to open a new folder. Name it whatever you want, then click on "Select Folder". It will appear in the *Visual Studio Code explorer.
Now from menu File → Save Workspace As.... Name the workspace and save it wherever you want to keep all your workspaces, (not necessarily where your project folders are). I put all mine in a folder called "Visual Studio Code workspace".
It will be saved as a (.code-workspace) file and is just an index to all the files and folders it contains (or points to) wherever they may be on your hard drive. You can look at it by opening it with a text editor. Close the folder you created and close Visual Studio Code.
Now find your workspace "file" and double click on it. This will open Visual Studio Code with the folder you created in your workspace. Or you can open Visual Studio Code and use "Open Workspace".
Any folders you create from within your Visual Studio Code workspace will be inside your first folder. If you want to add any more top level folders, create them first wherever you want them and then use "Add To Workspace.." from Visual Studio Code.
The title and subsequent question in the OP seem to boil down to:
What is a workspace in Visual Studio Code?
How do workspace settings work?
Short answer:
A workspace is a virtual collection of folders opened simultaneously in Visual Studio Code and defined in a .code-workspace file. Opening this file will open the collection of folders automatically. This is called a "multi-root" workspace.
The .code-workspace file also defines workspace settings that are used by the instance of Visual Studio Code where the workspace is opened.
When a workspace is not defined, i.e. you open a folder on its own, you can create "workspace settings" that are saved in a .vscode\settings.json file in the root of that folder structure.
In more detail:
Visual Studio Code uses the word "workspace" a little ambiguously in places. The first use to consider is in what is calls a multi-root workspace.
A multi-root workspace is a set of folders (the "roots") that are opened collectively in an instance of Visual Studio Code. There is no need for these folders to share parent folders; indeed that is the point since Visual Studio Code normally uses a single folder in the Explorer side-bar.
A multi-root workspace is defined by a .code-workspace (JSON) file which contains both the list of folders to be included in the workspace and Visual Studio Code settings.
Multi-root Workspaces
Regarding those workspace settings...
When you open menu File → Preferences → Settings the settings editor is shown. At the very least you should see a USER SETTINGS tab. These are the Visual Studio Code settings that are universal for your user account on your local machine. In Windows these are saved in %APPDATA%\Code\User\settings.json.
Visual Studio Code Settings File Locations
Individual folders (often each of the "root" folders in a workspace) might have a .vscode folder with their own settings.json file. When opened individually, i.e. not as part of a workspace, the content of these settings.json files is presented under the WORKSPACE SETTINGS tab, and all the settings in that file are used by the running Visual Studio Code instance.
When opening a multi-root workspace things behave differently. Firstly, the WORKSPACE SETTINGS tab shows the options set in the .code-workspace file. Secondly, any folder with a settings.json file will appear under a new FOLDER SETTINGS tab. Be aware that, when in a multi-root workspace, only a limited number of settings from each folder's settings.json are used. I suggest you open the link above to read further.
The main utility of a workspace (and maybe the only one) is to allow to add multiple independent folders that compounds a project. For example:
- WorkspaceProjectX
-- ApiFolder (maybe /usr/share/www/api)
-- DocsFolder (maybe /home/user/projx/html/docs)
-- WebFolder (maybe /usr/share/www/web)
So you can group those in a workspace for a specific project instead of have to open multiple folders windows.
You can learn more here.
On some investigation, the answer appears to be (a).
When I go to change the settings, the settings file goes into a .vscode directory in my project directory.
I just installed Visual Studio Code v1.25.1. on a Windows 7 Professional SP1 machine. I wanted to understand workspaces in detail, so I spent a few hours figuring out how they work in this version of Visual Studio Code. I thought the results of my research might be of interest to the community.
First, workspaces are referred to by Microsoft in the Visual Studio Code documentation as "multi-root workspaces." In plain English that means "a multi-folder (A.K.A "root") work environment." A Visual Studio Code workspace is simply a collection of folders - any collection you desire, in any order you wish. The typical collection of folders constitutes a software development project. However, a folder collection could be used for anything else for which software code is being developed.
The mechanics behind how Visual Studio Code handles workspaces is a bit complicated. I think the quickest way to convey what I learned is by giving you a set of instructions that you can use to see how workspaces work on your computer. I am assuming that you are starting with a fresh install of Visual Studio Code v1.25.1. If you are using a production version of Visual Studio Code I don't recommend that you follow my instructions because you may lose some or all of your existing Visual Studio Code configuration! If you already have a test version of Visual Studio Code v1.25.1 installed, **and you are willing to lose any configuration that already exists, the following must be done to revert your Visual Studio Code to a fresh installation state:
Delete the following folder (if it exists):
C:\Users\%username%\AppData\Roaming\Code\Workspaces (where "%username%" is the name of the currently logged-on user)
You will be adding folders to Visual Studio Code to create a new workspace. If any of the folders you intend to use to create this new workspace have previously been used with Visual Studio Code, please delete the ".vscode" subfolder (if it exists) within each of the folders that will be used to create the new workspace.
Launch Visual Studio Code. If the Welcome page is displayed, close it. Do the same for the Panel (a horizontal pane) if it is displayed. If you received a message that Git isn't installed click "Remind me later." If displayed, also close the "Untitled" code page that was launched as the default code page. If the Explorer pane is not displayed click "View" on the main menu then click "Explorer" to display the Explorer pane. Inside the Explorer pane you should see three (3) View headers - Open Editors, No Folder Opened, and Outline (located at the very bottom of the Explorer pane). Make sure that, at a minimum, the open editors and no folder opened view headers are displayed.
Visual Studio Code displays a button that reads "Open Folder." Click this button and select a folder of your choice. Visual Studio Code will refresh and the name of your selected folder will have replaced the "No Folder Opened" View name. Any folders and files that exist within your selected folder will be displayed beneath the View name.
Now open the Visual Studio Code Preferences Settings file. There are many ways to do this. I'll use the easiest to remember which is menu File → Preferences → Settings. The Settings file is displayed in two columns. The left column is a read-only listing of the default values for every Visual Studio Code feature. The right column is used to list the three (3) types of user settings. At this point in your test only two user settings will be listed - User Settings and Workspace Settings. The User Settings is displayed by default. This displays the contents of your User Settings .json file. To find out where this file is located, simply hover your mouse over the "User Settings" listing that appears under the OPEN EDITORS View in Explorer. This listing in the OPEN EDITORS View is automatically selected when the "User Settings" option in the right column is selected. The path should be:
C:\Users\%username%\AppData\Roaming\Code\User\settings.json
This settings.json file is where the User Settings for Visual Studio Code are stored.
Now click the Workspace Settings option in the right column of the Preferences listing. When you do this, a subfolder named ".vscode" is automatically created in the folder you added to Explore a few steps ago. Look at the listing of your folder in Explorer to confirm that the .vscode subfolder has been added. Inside the new .vscode subfolder is another settings.json file. This file contains the workspace settings for the folder you added to Explorer a few steps ago.
At this point you have a single folder whose User Settings are stored at:
C:\Users\%username%\AppData\Roaming\Code\User\settings.json
and whose Workspace Settings are stored at:
C:\TheLocationOfYourFolder\settings.json
This is the configuration when a single folder is added to a new installation of Visual Studio Code. Things get messy when we add a second (or greater) folder. That's because we are changing Visual Studio Code's User Settings and Workspace Settings to accommodate multiple folders. In a single-folder environment only two settings.json files are needed as listed above. But in a multi-folder environment a .vscode subfolder is created in each folder added to Explorer and a new file, "workspaces.json," is created to manage the multi-folder environment. The new "workspaces.json" file is created at:
c:\Users\%username%\AppData\Roaming\Code\Workspaces\%workspace_id%\workspaces.json
The "%workspaces_id%" is a folder with a unique all-number name.
In the Preferences right column there now appears three user setting options - User Settings, Workspace Settings, and Folder Settings. The function of User Settings remains the same as for a single-folder environment. However, the settings file behind the Workspace Settings has been changed from the settings.json file in the single folder's .vscode subfolder to the workspaces.json file located at the workspaces.json file path shown above. The settings.json file located in each folder's .vscode subfolder is now controlled by a third user setting, Folder Options. This is a drop-down selection list that allows for the management of each folder's settings.json file located in each folder's .vscode subfolder. Please note: the .vscode subfolder will not be created in newly-added explorer folders until the newly-added folder has been selected at least once in the folder options user setting.
Notice that the Explorer single folder name has bee changed to "UNTITLED (WORKSPACE)." This indicates the following:
A multi-folder workspace has been created with the name "UNTITLED (WORKSPACE)
The workspace is named "UNTITLED (WORKSPACE)" to communicate that the workspace has not yet been saved as a separate, unique, workspace file
The UNTITLED (WORKSPACE) workspace can have folders added to it and removed from it but it will function as the ONLY workspace environment for Visual Studio Code
The full functionality of Visual Studio Code workspaces is only realized when a workspace is saved as a file that can be reloaded as needed. This provides the capability to create unique multi-folder workspaces (e.g., projects) and save them as files for later use! To do this select menu File → Save Workspace As from the main menu and save the current workspace configuration as a unique workspace file. If you need to create a workspace "from scratch," first save your current workspace configuration (if needed) then right-click each Explorer folder name and click "Remove Folder from Workspace." When all folders have been removed from the workspace, add the folders you require for your new workspace. When you finish adding new folders, simply save the new workspace as a new workspace file.
An important note - Visual Studio Code doesn't "revert" to single-folder mode when only one folder remains in Explorer or when all folders have been removed from Explorer when creating a new workspace "from scratch." The multi-folder workspace configuration that utilizes three user preferences remains in effect. This means that unless you follow the instructions at the beginning of this post, Visual Studio Code can never be returned to a single-folder mode of operation - it will always remain in multi-folder workspace mode.
Short Answer:
Use a folder instead of single-folder workspaces.
Only use multi-root Workspaces if needed. You need multi-root workspaces when you need to work with multiple project folders. This can be very helpful when you are working on several related projects at one time. For example, you might have a repository with a product's documentation which you like to keep current when you update the product source code.
Why "Only use multi-root workspaces if needed"?
There is only basically two differences between single-folder workspaces and a folder:
you open a single-folder workspaces by File > Open Workspace... and then select a <name>.code-workspace file. You open a folder by File > Open Folder... and then select a folder.
When you open a single-folder workspaces using <name>.code-workspace file, all project specific settings will be added into the <name>.code-workspace file. When you open a project using folder, all project specific settings will be saved in .vscode/settings.json file.
Even if you take the time to create a <name>.code-workspace file for a single-folder workspaces, you can open that by menu File → Open Folder.... Depending on your access method, sometimes the settings can be in .vscode/settings.json file or <name>.code-workspace file. Better use a consistent method to access your project folders. Moreover, launch configurations (.vscode/launch.json) are saved beside Folder Settings (.vscode/settings.json) and not Workspace Settings (<name>.code-workspace). Most of the time, you will need the .vscode directory anyway.
Long Answer:
The documentation says:
The concept of a workspace enables VS Code to:
Configure settings that only apply to a specific folder or folders but not others.
Persist task and debugger launch configurations that are only valid in the context of that workspace.
Store and restore UI state associated with that workspace (for example, the files that are opened).
Selectively enable or disable extensions only for that workspace.
In another place, it says:
Configurations can be overridden at multiple levels by the different
setting scopes:
User settings - Apply globally to all VS Code instances.
Workspace setting - Apply to the open folder or workspace and override User settings.
Workspace Folder settings - Apply to a specific folder of a multi-root workspace. Override User and Workspace settings.
So, there is basically three types of settings:
Folder settings (highest precedence)
Workspace settings
User settings (lowest precedence)
You can modify folder settings by assigning a keybinding to Preferences: Open Folder Settings and then using the keybinding.
You can modify workspace settings by Ctrl + Shift + P → Preference: Open Workspace Settings.
You can modify user settings by File → Preferences → Settings.
Your workspace settings will be added into the <name>.code-workspace file.
Your folder settings will be saved in the .vscode/settings.json file.
There is Confusion
Evidence 1:
You may see the terms "folder" and "workspace" used interchangeably in
VS Code documentation, issues, and community discussions. Think of a
workspace as the root of a project that has extra VS Code knowledge
and capabilities.
Evidence 2:
A VS Code "workspace" is usually just your project root folder.
Workspace settings as well as debugging and task configurations are
stored at the root in a .vscode folder.
Evidence 3:
The visual difference of having a folder opened versus opening a
.code-workspace file can be subtle. To give you a hint that a
.code-workspace file has been opened, some areas of the user interface
(for example, the root of the File Explorer) show an extra (Workspace)
suffix next to the name.
Where is the Confusion?
The devil is in the details (documentation and implementation).
Documentation
In the documentation, they said different things is different places. There is no consistency.
In one place they say:
VS Code provides two different scopes for settings:
User Settings - Settings that apply globally to any instance of VS Code you open.
Workspace Settings - Settings stored inside your workspace and only apply when the workspace is opened.
In another place they say:
Configurations can be overridden at multiple levels by the different
setting scopes:
User settings - Apply globally to all VS Code instances.
Workspace setting - Apply to the open folder or workspace and override User settings.
Workspace Folder settings - Apply to a specific folder of a multi-root workspace. Override User and Workspace settings.
So, basically they did not consistently say that there are three levels of settings. Specially look at the title of their documentation for settings. It is titled User and Workspace Settings (notice how the Folder settings is missing from the title). It mentions Workspace Folder settings only once when they are talking about settings precedence.
Implementation
The documentation says:
Workspace settings enable you to configure settings in the context of
the workspace you have opened and always override global user
settings. They are physically stored in a JSON file and their location
depends on whether you opened a folder as a workspace or you opened a
.code-workspace file.
So, basically, when there isn’t any workspace (for example, you did not open the project using <name>.code-workspace) and you Ctrl + Shift + P → Preference: Open Workspace Settings, it opens the .vscode/settings.json file (which is actually for folder settings and not workspace settings, though the name explicitly says Open Workspace Settings).
You might have already noticed in the Long Answer: that "they" did not keep any easy way to directly access folder settings (you have to assigning a keybinding to the Preferences: Open Folder Settings command and then use the keybinding. You can not even access this "Command" from the Command Pallet using Ctrl + Shift + P directly).
Moreover, you have to modify folder settings using Preference: Open Workspace Settings (note that you are modifying "Folder settings" using "Open Workspace Settings"). Whether Preference: Open Workspace Settings will modify folder settings or workspace settings depends on how you access the project (using menu File → Open Folder... or the <name>.code-workspace file).
They made a simple thing hard by trying to oversimplify it.
As of May 2018, it seems that a workspace in Visual Studio Code allows you to have quick access to different but related projects. All without having to open a different folder.
And you can have multiple workspaces too. See references here and you will get the full picture of it:
Reference 1
Reference 2
They call it a multi-root workspace, and with that you can do debugging easily because:
"With multi-root workspaces, Visual Studio Code searches across all folders for
launch.json debug configuration files and displays them with the
folder name as a suffix."
Say you have a server and a client folder inside your application folder. If you want to debug them together, without a workspace you have to start two Visual Studio Code instances, one for server, one for client and you need to switch back and forth.
But right now (1.24) you can't add a single file to a workspace, only folders, which is a little bit inconvenient.
Just added in February 2021 is this documentation on "What is a VS Code 'workspace'": workspaces.
A Visual Studio Code "workspace" is the collection of one or more
folders that are opened in a VS Code window (instance). In most cases,
you will have a single folder opened as the workspace but, depending
on your development workflow, you can include more than one folder,
using an advanced configuration called Multi-root workspaces.
The concept of a workspace enables VS Code to:
Configure settings that only apply to a specific folder or folders but
not others. Persist task and debugger launch configurations that are
only valid in the context of that workspace. Store and restore UI
state associated with that workspace (for example, the files that are
opened). Selectively enable or disable extensions only for that
workspace. You may see the terms "folder" and "workspace" used
interchangeably in VS Code documentation, issues, and community
discussions. Think of a workspace as the root of a project that has
extra VS Code knowledge and capabilities.
Note: It is also possible to open VS Code without a workspace. For example, when you open a new VS Code window by selecting a file from
your platform's File menu, you will not be inside a workspace. In this
mode, some of VS Code's capabilities are reduced but you can still
open text files and edit them.
Single-folder workspaces
You don't have to do anything for a folder to become a VS Code
workspace other than open the folder with VS Code. Once a folder has
been opened, VS Code will automatically keep track of things such as
your open files and editor layout so the editor will be as you left it
when you reopen that folder. You can also add other folder-specific
configurations such as workspace-specific settings (versus global user
settings) and task definition and debugging launch files (see below in
the workspace settings section).
Multi-root workspaces
Multi-root workspaces are an advanced capability of VS Code that allow
you to configure multiple distinct folders to be part of the
workspace. Instead of opening a folder as workspace, you will open a
.code-workspace JSON file that lists the folders of the
workspace. For example:
{
"folders": [
{
"path": "my-folder-a"
},
{
"path": "my-folder-b"
}
]
}
A multi-root workspace opened in VS Code
Note: The visual difference of having a folder opened versus opening a .code-workspace file can be subtle. To give you a hint that a
.code-workspace file has been opened, some areas of the user interface
(for example, the root of the File Explorer) show an extra (Workspace)
suffix next to the name.
And much more at the first link.
Although the question is asking "what is a workspace?", I feel that the source of confusion is the expectation that workspaces should behave more like "projects" in other editors.
So, I to help all the people landing here because of this confusion, I wanted to post the following plugin for Visual Studio Code (not mine), Project Manager.
It has a nice UI for managing (saving and opening) single-folder projects:
Save Projects:
Open projects with the palette:
See the current project in the status bar (click to open project palette):
Access projects in the sidebar:
Open the File menu and select Save Workspace As. That will save the current explorer status.
After that you can chose menu File* → Open Workspace to open the before-saved workspace.
If the Visual Studio Code is a fresh installation;
Click on extensions, search for "python" and click on Install
Click on menu View → Explorer
If there in no folder added a folder to the Workspace (menu File → Add folder to Workspace)
If you want to use a virtual Python environment, click on menu File → Preference → Settings
Click on "{} open settings JSON" which is in top right corner of the window, and then add the path to python.exe file which is in the virtual environment:
{
"python.pythonPath": "C:\\PathTo\\VirtualENV\\python.exe"
}
Start a new terminal and check the correct Python interpreter is selected
This is a must read to understand workspaces.
As many have pointed out, multi-root workspaces are where the Visual Studio Code workspace concept becomes relevant.
But why is another question.
So here is an excerpt from the Eclipse IDE user guide, which got the workspace concept right, amongst other things (totally different to Visual Studio Code, and if you need Visual Studio Code, you shouldn't switch to Eclipse - but you can read the documentation because they explain it right):
Considerations for Git Repositories to be used in Eclipse
The short story
When setting up Git Repositories with EGit, there are two recommendations for the creation of "productive" (as opposed to "playground") Repositories:
Don't create the Repository within the Eclipse workspace.
Be careful when cloning or creating a Repository.
Make sure to use the Git Sharing Wizard correctly.
Don't create a Repository with an Eclipse project as root.
Make sure to use the Git Sharing Wizard correctly.
The first mistake happens when you specify a workspace folder during cloning or creation of a Repository.
Both mistakes will happen when you use the Git Sharing Wizard from an Eclipse project that you have created manually in your workspace without taking precautions (the wizard has been fixed in the latest version).
Below you will find some motivation for these recommendations.
The longer story
Eclipse Workspace and Repository working directory
Git Repositories can be created in different ways, for example by cloning from an existing Repository, by creating one from scratch, or by using the EGit Sharing wizard.
In any case (unless you create a "bare" Repository, but that's not discussed here), the new Repository is essentially a folder on the local hard disk which contains the "working directory" and the metadata folder. The metadata folder is a dedicated child folder named ".git" and often referred to as ".git-folder". It contains the actual repository (i.e. the Commits, the References, the logs and such).
The metadata folder is totally transparent to the Git client, while the working directory is used to expose the currently checked out Repository content as files for tools and editors.
Typically, if these files are to be used in Eclipse, they must be imported into the Eclipse workspace in one way or another. In order to do so, the easiest way would be to check in .project files from which the "Import Existing Projects" wizard can create the projects easily. [...]
Implication
The above has the following implications:
It is probably not a good idea to make a project the root folder of your Repository.
The reason is that you will never be able to add another project to this Repository, as the .project file will occupy the root folder; you could still add projects as sub-folders, but this kind of project nesting is known to cause lots of problems all over the place. In order to add another project, you would have to move the project to a sub-folder in the Repository and add the second project as another sub-folder before you could commit this change.
It is a good idea to keep your Repository outside of your Eclipse Workspace.
There are several reasons for this:
The new Repository will consider the complete folder structure of the Eclipse workspace as (potential) content. This can result in performance issues, for example when calculating the changes before committing (which will scan the complete .metadata folder, for example); more often than not, the workspace will contain dead folders (e.g. deleted projects) which semantically are not relevant for EGit but cannot be excluded easily.
The metadata (.git-) folder will be a child of the Eclipse Workspace. It is unclear whether this might cause unwanted folder traversals by Eclipse.
You can easily destroy your Repository by destroying your Eclipse Workspace.
This being said, Visual Studio also got it right; why Microsoft decided to disregard the Solutions (.sln) and Project (.vcxproj) concepts in Visual Studio Code is rather intriguing.
Simple answer: actually it's like a new buffer in the Vim editor
Do you ever have to built a new directory and open a new Visual Studio Code window for a test project or for a feature that you want to add to your main project? Ok, so you need a workspace and enough CPU high usage...
I just wanted to mention a common usage of workspaces in Visual Studio Code in addition to all other answers.
A workspace, in my opinion, something that everyone forgot to mention, is a way to create an area with all tools you need to address a single language, like other said, in one project you might have PHP, Python, JavaScript, Node.js, etc.
Creating a workspace for each specific language, you can have all tools for managing, debugging, testing, for example all your JavaScript.
This is much easier to manage, so you can have a workspace for PHP, another for Node.js, ... and one project that have folders in multiple workspaces.

Aptana/Eclipse: How do I make a project that uses existing files on my filesystem, instead of copying?

I want to create a project that uses source files already on my filesystem, but the IDE always wants to create a directory and make a second copy of all the source.
This has always annoyed me about Aptana and Eclipse, is there a workaround for this?
I am using Aptana Studio 3 on my mac and the way I do it is:
Click on File
Select Import from the dropdown menu
Select the General tab and open it, you will see the option Existing Folder as New Project
Select it and click on Next
On the next page select the folder where you have the old project files, name the new project(if you want to change it). You can also select the languages that you have used on the project.
Click Finish and you are set to go.
One small addendum, the existing folder doesn't actually need to be in your workspace. I have several projects in my workspace but also several located elsewhere for assorted reasons.
have the files in a directory under your workspace
use "create project" and change the default folder to the one created above.
I too wasn't aware of how to do this..
But i tried this way and it worked..
Step 1: Try to create new workspace with the name and location as you wish
Step 2: click new->Java Project
Step3: In the create a Java Project Window select the option for Creating from existing Resource" and select the resource you want
Step4: You can see the project name as automatically set by itself based on the folder containing the project that you select.
Step5: click finish
Step 6: I guess, you need to open Navigator view(Window->show view-> navigator) for best viewing
Hope this works gud.. Post here if its not working,..
There is a checkbox named "Prompt for workspace on startup". It's in Window -> Preferences -> General -> Startup and Shutdown -> Workspaces. If you check this, on next Aptana startup you will be prompted to define a new Default workspace directory which would be your default projects folder.
There is also another way to do that.
Create an empty project (right-click in the Project Window and go to "New->Project" and then "General->Project" and click "Next", after that type in a project name and click "Finish").
Add a new connection to this project (right-click on "Connections" and then "Add New Connection"). The "Source" should be your project and the "Destination" should be the type "Filesystem" with a folder of your choice.
Finished.
I only use that method in very rare cases, as example, if u need a simple file-reference of any folder on your harddrive or if you need an overall file-reference to your workspace folder which contains all project folders, etc..
This answer by no means solves the issue above in Aptana but if you are in a rush, try using FreeCommander http://www.freecommander.com. It is a dual pane file manager with a slew of options. I have been using it for almost 3 years and there is never a day I don't use it.
What I did for now, is I allowed Aptana to create a folder in the workspace at the same level as the original folder I would like to use. Using FreeCommander I then have the original (src) folder in one pane with the new folder (dst) in the other pane.
I then manually copy (F5) or use FreeCommander's built in sync function (Alt + s) so that both folders have the same contents at all times.
Again, not the right answer but a workaround as work needs to be done. Cheers.