Naming folders in VSCode workspaces

alexsaezm

Álex Sáez

Posted on November 22, 2022

Naming folders in VSCode workspaces

For my packaging work in Fedora, CentOS and RHEL, I use VSCode as my main editor. And more often than not, I find myself working on a bug that requires more than one repository.

This happens because packages are “small” (you should look at Kubernetes…) projects that isolate the thing you want to manage, so a project with multiple dependencies usually involves more than one package. This is really common in Fedora, as bundling is discouraged.

VSCode workspaces are a great feature that significantly helps me in those situations. How? I create a workspace with all the repositories and name it like the bug I’m working on (for example, rhbzXXXXX, rhbz stands for Red Hat Bugzilla). And for quick access, I keep all of my workspace files in the same folder. As simple as it sounds. But this usually leads to a minor problem that can become annoying. What if the folders have the same, similar, or just a non-clear name? VSCode and the documentation don’t give us any solution. But the workspace file is JSON and allows two parameters I didn’t find in the documentation: name and uri. Not quite sure what exactly uri does, but as you can imagine, you can use name to modify the interface text and show more practical information. For example:

{
    "folders": [
        {
            "path": "../src/gitlab.com/redhat/centos-stream/rpms/go-rpm-macros",
            "name": "CentOS Stream macros"
        },
        {
            "path": "../src/src.fedoraproject.org/rpms/go-rpm-macros",
            "name": "Fedora macros"
        }
    ],
    "settings": {}
}
Enter fullscreen mode Exit fullscreen mode

To open this file quickly, open the Command Palette (usually Ctrl + Shift + P), and look for “Open Workspace Settings (JSON)”.

The only remaining issue is that workspaces don’t allow you to specify the branch, so unless you use some CVS branch workflow or git-worktree, if you reopen an old workspace, it will be a mess. Although I never found myself in this situation.

💖 💪 🙅 🚩
alexsaezm
Álex Sáez

Posted on November 22, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related