Open the same directory twice

2020-05-19 04:03发布

问题:

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?

回答1:

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)



回答2:

in latest version it is actually much simpler. In the tab of the project you want to duplicate, open the command panel (Command + shift + P in Mac), then type dupl, this will duplicate your workspace in new window. Now you can have 2 versions of the same project at the same time.



回答3:

Click Add workspace folder... and open the same folder. Works for me, other solution doesn't work, just jump focus to another window.



回答4:

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.