Luce Carter Logo

  • tips
  • software development
  • cli
  • tooling
  • vscode
  • web development

VS Code CLI Tip: Open in the same window

A while ago, I was watching the amazing Corey Weathers stream and saw him doing something amazing in CLI (command-line/terminal) that blew my mind..reusing an existing window!

How often do you find that you open VS Code from CLI and it opens in a new window, so you close an existing window that you don't need anymore? I know I do that often as I jump between projects and don't think to close a window.

Well did you know there is a super easy fix for that? Just append -r. For example with the standard non-preview version of VS Code, you can use the following code:

code . -r

This opens the current folder you are in within your CLI in VS Code while reusing the window, amazing! If you are like me and use VS Code Insider, their preview build, the command is:

code-insiders . -r

Amazing! Happy coding! 🧡