- One Tip a Week
- Posts
- One Tip a Week: Open VS Code in the Same Editor
One Tip a Week: Open VS Code in the Same Editor
Welcome to the inaugural tip of the week for the One Tip a Week newsletter. The goal is short and helpful tips to help you level up as a dev.
This week’s tip of the week is for VS Code. I frequently use this one.
The assumption with this tip is that you have configured VS Code to run from the terminal.
Say you’re in the terminal in VS Code and you want to open an existing project from the command line. You can run code ../my-other-project
. This opens a new instance of VS Code. In the past when I did this, I would close the one where I ran the command in the terminal and continue working on the newly loaded project.
There must be a better way!
Indeed, there is a better way. Run the command like above, but add -r
, e.g. code ../my-other-project -r
. This opens the new project and reuses the existing VS Code instance.
And if you want to get fancy, you can create an alias for it. This is mine in my ZSH configuration.
If you use other editors based off of the core of VS Code, like cursor, you can do the same thing there.
That’s it! Short and sweet. Until the next one!