Some Little Improvements to My VS Code Workflow (Workspaces, Icons, Tasks)
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,
}
}
The post Some Little Improvements to My VS Code Workflow (Workspaces, Icons, Tasks) appeared first on CSS-Tricks.