Cannot open saved workspace in vscode - visual-studio-code

I have created a workspace with five folders in it. It works fine whenever I first create it. I go File > Save Workspace as and save it in my Documents directory. Then I close and reopen VSCode and go to open the workspace, and it isn't there. I go to open recent workspaces, and there are no files visible in explorer window. I can open the workspace configuration file but I cannot open the workspace itself.
I'm on Linux Mint tessa

I found the problem. The workspace was saved without a file extension. I manually added .code-workspace to the filename and now I can open it as a workspace.

Related

Open the multi-root workspace file by default when openning the project directory

Is there a way to open the .code-workspace file when opening the project root directory via the CLI? In other words, instead of needing developers to use the command code project.code-workspace, they can just enter code <project-root-dir>?

VScode Folder automatically closes when vscode get closed

Before:
After:
When i am doing quit(cmd+Q) and reopening it, it loads the previous folder which i am working at, but if i press the top left red button and reopen everything is gone, i have to reopen the folder.
You can choose the corresponding settings in Window: Restore Window. Default is all
If you prefer the settings.json
"window.restoreWindows": "all"
Copied from vscode document:
Controls how windows are being reopened after starting for the first
time. This setting has no effect when the application is already
running.
preserve: Always reopen all windows. If a folder or workspace is opened (e.g. from the command line) it opens as a new window unless it
was opened before. If files are opened they will open in one of the
restored windows.
all: Reopen all windows unless a folder, workspace or file is opened (e.g. from the command line).
folders: Reopen all windows that had folders or workspaces opened unless a folder, workspace or file is opened (e.g. from the command
line).
one: Reopen the last active window unless a folder, workspace or file is opened (e.g. from the command line).
none: Never reopen a window. Unless a folder or workspace is opened (e.g. from the command line), an empty window will appear.

Edit existing directory in eclipse

This might be a dumb question, but I have a project I am trying to edit a few files for and using eclipse 4.20.0 as an IDE.
When I try to import the directory in eclipse, it creates a completely separate eclipse workspace directory and stores the files in there for my editing. (When I make changes, files in the eclipse workspace directory are changed, but not the original directory)
Is there a way to open the original directory in Eclipse and edit files directly in there? Or am I going to have to work inside the directory eclipse created and then manually move the files over every time to test them again?
I swear I've done this before, but it's been a few years so I might just be importing the directory wrong.
If you are only making a couple changes, just clicking on the .java class you need in your explorer and "Open With... -> Eclipse IDE" will allow you to edit the specific file without opening up a new project. If you are trying to open the project and work on all the files at once, File > Open Projects from File System usually works pretty well on eclipse. If you are opening another eclipse project, just click on the folder where the .project is stored when opening, not necessarily clicking into the folder itself.

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.

How to create a workspace

How do we create a workspace in Visual Studio Code?
I see File menu commands to open, add a folder to and save a workspace, but nothing to create one.
The questions How can I create a workspace in Visual Studio Code? and How can I create a Visual Studio Code Python workspace? are specific to Python. I am asking how to create a generic workspace.
The question What is a 'workspace' in Visual Studio Code? provides some explanation of what they are, but it is not clear how to create them.
I had your same question, but the answer is simple, you don't. There is no need to start a blank workspace. To start on a new project use Open Folder from the File menu: navigate to the project, create a folder if needed, and then select the folder. You are now working on any files within that folder as if it were a workspace. If you leave and open another folder or workspace with files still open in editors, those files will be open when you open that folder again. Visual Studio Code making things work effortlessly! Until you do something that specifically requires a workspace you don't have to save it. If you save a workspace with no settings changed to the root folder here's what it looks like: {"folders": [{"path": "."}],"settings": {}}. That's it. The open editors are saved internally regardless of whether you saved as workspace. Starting by saving a blank workspace is like having an empty file cabinet in your office. VSCode will inform you if you ever need that and you can save a workspace then.
I finally had a chance to use VSC on a Mac. The difference on a Mac is
that Open File and Open Folder are under the same general Open
command (apparently because Macs use the same browser to select files and folders). Just use that to Open a folder, and open files in that folder workspace using the VSC explorer. All this still applies. The folder is the workspace.
You only need to save that workspace if you want to Add Folder to Workspace (in which case VSC will prompt you to save your multiroot workspace if you exit, or if you want to save settings specific to your project folder (though you can do that without a workspace using a settings json in a .vscode folder within). Even then VSC will auto save workspace settings for the folder internally when you haven't explicitly made the project folder a workspace.
Do you need a workspace and the extra .code-workspace file involved? If you have multiple root folders it's certainly nice to open the workspace and have those all there in your next session. If it's just for settings for a project with one root it's not needed (maybe if you want a file you can share with others on the project), and if the reason you are changing settings per project is language related then it may make far more sense to add language settings to your main settings file and have them in effect every time you work on that kind of project.
In short every time you use Open Folder workbench.action.files.openFolder you are essentially switching to another workspace.
In the folder you want to add to your workspace, create a file {foldername}.code-workspace and in the file put in the following code.
{
"folders": [
{
"path": "."
}
]
}
Save and close the file. Back in Visual Studio Code, click menu File → Open Workspace... and select the .code-workspace file you created and it will open it as a new workspace without having to add a folder to an existing workspace.
In the File menu choose "Open Folder...". Select a folder. You can add folders to the workspace using "File" | "Add Folder to Workspace...".
Optionally, also go to "File" | "Preferences" | "Settings". The "User Settings" tab will be open by default. Look for the "Workspace Settings" tab and select it. Modify a setting, such as change the theme.
Then you can save the workspace using "Save" in the File menu.
When you close the workspace using "Close Workspace" in the File menu then if you changed the theme for the workspace then the theme should revert to the global theme. When you re-open the workspace VS Code will open the folder(s) that were added to the workspace and apply whatever settings that were specified for the workspace. There are a few settings that are ignored for workspaces for security reasons but all other settings can be overridden in workspaces.
It is possible to add multiple projects to a workspace; see Multi-root Workspaces.
If you already have a window open with project files or folders, and you want a new workspace to work on a different project:
From the 'File' menu, choose 'New Window'
From the 'File' menu, choose 'Add Folder to Workspace' and choose the root folder of your project
The new window is the workspace for your new project. You can save it to a named file with 'File', 'Save Workspace As...'
(The above instructions refer to Visual Studio Code 1.36.1 on macOS.)
Close all open files in VS Code.
Select File menu >> Open Folder... and open the folder containing your source files.
Select File Menu >> Save Workspace as... it should default to the folder you previously opened. If not browse to it and save the workspace file.
To create a new workspace in Visual Studio Code press F1 (or Crtl+Shift+P) and choose 'AL: GO!'