20

Software : Visual Studio Code

OS : macOS 10.14

Version : 1.28.2 (1.28.2)

I have a folder that I work on every time with VSC, no other requirements. I want to open this folder as a folder/workspace by default on launch of VSC so that I don't have to browse through and open that workspace again. How can I change settings/ write a script so that when I launch VSC, that workspace opens up automatically.

0

3 Answers 3

18

Set the settings

"files.hotExit": "onExitAndWindowClose" "window.restoreWindows": "folders" 

Note if you launch VSC by a file in explorer, it will not open the file in your current workspace and the workspace information will be lost (you'll have to open the workspace manually again on saving)

Sign up to request clarification or add additional context in comments.

2 Comments

Note if you launch VSC by a file in explorer, it will not open the file in your current workspace and the workspace information will be lost (you'll have to open the workspace manually again on saving) - Can this behavior be corrected?
A better explanation would help me. I tried to use multiple workspace files so that I can edit my Markdown cookbooks in one VS Code Window, and code in another, but after doing that each time I open VS Code my workspace is gone and I have to load it from a file. Does this sound like this is the fix for my problem?
10

You can set the setting of window.restoreWindows to preserve :

Settings : restoreWindows

This will reopen your workspace even if you open a file and Visual Studio code is not already opened on your workspace.

1 Comment

Thanks, this was exactly what I wanted -- The only workspace I use is my "PowerShell" folder, occasionally I create .ps1 files outside this location and VS code opens these in orphaned windows, if I try to open my 'normal' workspace it closes the file I just opened (not helpful!)... Your suggestion keeps my "PowerShell" folder/workspace regardless of which file I edit, where it is stored, or whether I open this from the cmd line, file or explorer or any other way, perfect! 👍🏼
4

You can pass the path of .code-workspace file as an argument to code.

code /path/to/your.code-workspace 

You may just update your default Code shortcut based on this.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.