josinalvo
josinalvo

Reputation: 1488

in vscode, can I open a directory in the current window via the terminal/cli

As per the title

If I go to the VSCode terminal and type code <name of dir>, it opens the directory in a new VSCode window. I wish there was a way to open it in the current window (perhaps using another command, or choosing some option in preferences)

Is there?

Upvotes: 14

Views: 8353

Answers (3)

Mark
Mark

Reputation: 182821

There is a setting not for the command line but for opening a folder from a menu or command:

Window: Open Folders in New Window // set to 'off'

or use the -r switch (for 'reuse the same window) in the command line, see Command Line options

code -r <folder-name>

Upvotes: 28

codemonkeytony
codemonkeytony

Reputation: 190

Very old question but I've just started using VS Code and found that "code -r ." did the trick. Hope this helps someone out.

Upvotes: 1

Ishan Bassi
Ishan Bassi

Reputation: 562

You can use ctrl + K + O and select a folder to open.

Upvotes: -1

Related Questions