YulePale
YulePale

Reputation: 7726

How to change current working directory in VS Code?

How to change current working directory in VS Code?

Let's say, I have a parent folder called apps and inside it I have a child folder called MyBeautifulApp and I opened the apps folder using vscode. What command sould I run on the commandline to not only cd into MyBeautifulApp but also change the directory so that it seems like I opened MyBeautifulApp using VS Code and did not just cd into it?

Upvotes: 12

Views: 105762

Answers (4)

Tamseel Ahmad
Tamseel Ahmad

Reputation: 13

Simply type:

code directoryName -r

If you are already in that directory:

code . -r

The -r flag replaces the current window with the new window. If you want to open a new window instead of replacing, skip the -r flag

Upvotes: 1

Syed Muhammad Hassaan
Syed Muhammad Hassaan

Reputation: 31

Reuse an Active Window

We can achieve this by using code --reuse-window path or use the short version code -r path This CLI will change the current directory of your VS code without opening a new window because as it name says it is reusing the active window

VS Code CLI

For more understanding of VS code CLI go to VS Code Official CLI

Or Hit code -h for more CLI references

Upvotes: 2

DeepDarkDoor
DeepDarkDoor

Reputation: 121

In File select Close Folder, and you will go back to the main menu, where you can select a new folder as the new working directory.

Upvotes: 12

user14009196
user14009196

Reputation:

Just close Visual Studio Code and open it in the right folder again.

close program

code MyBeautifulApp/

OR

Press Command + O and open your folder.

Upvotes: 5

Related Questions