I did a little thing the other day that I didn’t know was possible until then. I had a project folder open in VS Code like I always do, and I added another different root folder to the window. I always assumed when you had a project open, it was one top level root folder and that’s it, if you needed another folder elsewhere open, you would open that in another window. But nope!
We kind of have a “duo repo” thing going on at CodePen (one is the main Ruby on Rails app, and one is our microservices), and now I can open them both together:

Now I can search across both projects and basically just pretend like it’s one big project.
When you do that for the first time and then close the VS Code window, it will ask you if you want to save a “Workspace.” Meh, maybe later, I always thought. I knew what it meant, but I was too lazy to deal with it. It’ll make a file, I thought, and I don’t really have a place for files like that. (I’d avoid the repo itself, just because I don’t want to force my system on anyone else.)
Well, I finally got over it and did it. I chucked all my .code-workspace
files into a local folder. They are actually quite useful as files, because I can put the files in my Dock and one-click open my Workspace just how I like it.
Custom Workspace icons
Workspace files have special little icons like this:

Since I’m putting these in my Dock, I saw that as a cool opportunity to make them into custom icons! That’ll make it super clear for me and a little more delightful to use since I’ll probably reach for them many times a day.
Taking a little inspiration from the original, I snagged the SVG logo and plopped it on the bottom-right of my project logos.

Changing logos on macOS is as simple as “Get Info” on the file, clicking the logo in that panel, then pasting the image.
Now I can keep them in my Dock and open everything with a single click:

Launch terminal commands when opening a project
Now that I have these really handy one-click icons for opening my projects, I thought, “How cool would it be if it kicked off the commands to start the project too!” Apparently, that’s what Tasks are for, and it wasn’t too hard to set up (thanks, Andrew!). Right next to that settings file, at .vscode/tasks.json
, is where I have this:
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Gulp",
"type": "shell",
"command": "gulp",
"task": "default",
"presentation": {
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": true
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
That kicks off the command gulp
for me whenever I open this Workspace. I guess you have to run the task once manually (Terminal → Run Task) so that it has the right permissions, then it works from there on out.

Overrides
I don’t think this is specific to Workspaces necessarily, but I really like how you can have a file like .vscode/settings.json
in a project folder to override VS Code settings for a particular project.
For example, here on CSS-Tricks, I have a super basic Sass setup where Gulp preprocesses .scss
into .css
. That’s all fine, but it’s likely that I’ll search for a selector at some point. I don’t need to see it in .css
because I’m not working in vanilla CSS. Like ever. I can put this in that settings file, and know that it’s just for this project, rather than all my projects:
{
"search.exclude": {
"**/*.css": true,
}
}
I like this guide, it’s great and I intend on trying it out.
But did you check out the Project Manager extension? I’ve been using it for years now and it’s great since it doesn’t require saving any files really.
I think you saved the best part for last :-)
These are features that I read about and thought “oh, that’s kinda kewl” and then forgot. Seeing them all put together like this and all of a sudden I’m seeing a private/personal Projects meta-project in my git(hub|lab) future.
Hey! One great thing I have done as an alternative to having a workspaces folder.
Save your workspace and VSCode specific files under your project repo in a .VSCode folder. Then just go configure your local gitignore file to ignore that directory and then you can access and edit it while in your workspace and Git with ignore the entire folder so you aren’t pushing your personal task configuration files to your remote host!
I’d suggest you try it out! It’s really convenient. If you still want to have those shortcuts on your desktop, you can create shortcuts (or go a step further and create soft/hard-links to the existing .workspace file in the project folder).
Cool post! Love the attention to detail, little things cause happiness after all
Helpful tips – I like the idea of putting the workspaces into dock
I appreciate that you took the time to write up these tips. Like so many others, things like workspaces are something that I brushed off as I was using VS Code for projects, but being able to utilize things like launching projects from my dock, or setting up custom settings and tasks is very practical.
Wow, I am really interested on how to replicate the taskbar icon per project in Windows!
How are you able to put a workspace in your Mac dock?
Like this:
That thing Geoff mentioned is about adding spaces to a dock, but you don’t really need that to put a Workspace in the dock. The part of the doc that accepts files in on the right (or bottom) after the divider. On the part with the trash can.
That’s great and fits to my workflow as well. I have created app in Apple Automatizor – this opens my Workspace, Local by Flywheel, Github Desktop and Codekit all in one click. (I also created app that closes all these apps in the end of the day)
How to put a workspace icon with custom icon on the Windows taskbar then?
Or do you not talk about it because it’d be just a shortcut file?
I don’t talk about it because I’ve never used Windows. If you do and have tried and succeeded, could you share?
You can create a link (lnk) to any file. Link to a file opens a default application (VSC in that case). Just drag workspace with right-click. Then choose an icon in the properties of the lnk and you are done.
You can put lnk in Quick Launch menu. So in:
This is how it looks:
https://ibb.co/cyLqC7k
Obviously you can do much better then I did when creating an icon .
You can create a shortcut with the command ‘Code.exe C:\Project\MyProject.code-workspace’ and then pin that shortcut to the taskbar. You can right-click on that, choose properties and change the icon. You will need to do this if you have vscode already pinned to your taskbar, as the default icon shown will be the same as vscode.
You can, of course, create the shortcut on the desktop as well and customize it first and then pin it. The point is that it’s easy to do.
About not searching in css, I’d counter that your build files should probably only exist in a build folder, which should be ignored by git and will therefore not appear in search results anyway (if the option is selected to exclude ignored files, which it likely is to avoid searching in node_modules etc)
Does VS Code automatically not search files that are in a
.gitignore
file? That’s nice. In my case, I commit my .css files. I probably shouldn’t, but not all build and deploy processes are ideal perfect things.This nudge about using the VS Code Tasks feature’s “runOn” option might be the thing that finally pushes me to using Workspaces (I was also in the “meh, maybe later” camp)! Very handy.
For what it’s worth, a Workspace can have its own settings that get saved inside of the
.code-workspace
file instead of in a.vscode
subdirectory, which might be ideal if you’re not wanting to share your setup with others working on the same repo, or the .gitignore approach doesn’t work for your setup.If you edit the
.code-workspace
file in VS Code (open it into the editor, I mean — is there a better UI way to get into this raw JSON config for the Workspace? I couldn’t find it…), you can set up both your per-Workspace settings and tasks like so:You still have to do the
Allow Automatic Tasks in Folder
thing after you first set this up, but otherwise it seems to work like a charm, and no pesky.vscode
folder in the repo!I was not prompted to update permissions after the task ran once manually (Terminal → Run Task). I had to manually
Allow Automatic Tasks in Folder
from the Command Palette.The next time I opened to workspace it worked like a charm! Thanks for the article!