Open the same directory twice
Visual Studio-CodeVisual Studio-Code Problem Overview
On command line, I could open a directory like:
code .
Now, I want two of the identical diretory opened and displayed in another window.
(It's not spliting the editor)
Then, I tried again.
code .
Nothing happened.
There's still one directory opened.
How to achieve such a task?
Visual Studio-Code Solutions
Solution 1 - Visual Studio-Code
You can do this with the following ways:
1- Manually open a new window (ctrlshiftn) and go to:
File > Add folder to Workspace. Then just select the folder.
2- Open the command panel (ctrlshiftp) enter dupl
and hit enter that will duplicate the current workspace in a new window
*dupl
is just a filter for the complete command that is: Workspaces: Duplicate Workspace in New Window
thanks to dipnlink comment
Source: https://code.visualstudio.com/docs/editor/multi-root-workspaces
*Done in windows (10), vscode (1.35.1)
Solution 2 - Visual Studio-Code
In the latest version, it is actually much simpler.
In a window of the project you want to duplicate, open the command panel (Command + Shift + P in Mac or Ctrl + Shift + P in Ubuntu), then type dupl
(and select Workspaces: Duplicate As Workspace in New Window
), this will duplicate your workspace in a new window. Now you can have 2 windows of the same project at the same time.
Solution 3 - Visual Studio-Code
Click Add workspace folder...
and open the same folder. Works for me, other solution doesn't work, just jump focus to another window.
Solution 4 - Visual Studio-Code
click file > duplicate workspace
Solution 5 - Visual Studio-Code
As far as I know, the accepted answer is not correct as C14L indicates.
It can be done by opening a different folder that includes the folder you're working in. So say we have /project
and /project/src
and /project/build
, you're probably interested in having src
open in two instances of VSCode, which you can achieve by opening /project
and /project/src
.
Solution 6 - Visual Studio-Code
In addition to accepted answer, here's the trick if you want to open same project in two different windows but showing two different git branches:
Copy the project folder and open that folder!
If you want two windows in two different git branches then this simple trick works. I don't know of any other solutions.
Solution 7 - Visual Studio-Code
The accepted answer works, but I don't really like the fact that the folder is opened into an unnamed workspace, and upon closing window, we will be prompted to save that workspace. I am expecting more like Sublime Text like behavior.
Luckily there is VSCodium, VSCode's twin/clone without telemetry to Microsoft. So I ended up opening the folder once in either VSCode or VSCodium, then a second time in the other. This so far worked quite well for me.