413

Today Microsoft released the Visual Studio Code file/folder editor.

The first limitation is it appears to be a single-instance application.

Is there a way of getting multiple instances, or otherwise having it open multiple folders simultaneously?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Binary Worrier
  • 50,774
  • 20
  • 136
  • 184
  • See also: [Visual Studio Code open tab in new window](https://stackoverflow.com/questions/43362133/visual-studio-code-open-tab-in-new-window/43362800#43362800) – Gabriel Staples Oct 15 '21 at 00:45
  • See also the comments posted by these users @ Support to open a project folder in multiple VS Code windows · Issue #2686 · microsoft/vscode · GitHub: [Linux workaround](https://github.com/microsoft/vscode/issues/2686#issuecomment-228305016) and [Windows workaround](https://github.com/microsoft/vscode/issues/2686#issuecomment-390957613) The windows workaround works better with a hard link IMO. – StickySli Apr 24 '22 at 09:19

21 Answers21

664

Ctrl + Shift + N will open a new window, while Ctrl+K then releases the keys, and pressing O would open the current tab in a new window. You can then use menu FileOpen Folder to have two instances of Visual Studio Code with different folders in each window.

For Mac:

  • + Shift + N (Open new Window)
  • + K then release the keys and press O (open current Tab in new Window)

List of helpful keyboard shortcuts can be found here.

Samuel
  • 356
  • 2
  • 13
Blake Mumford
  • 17,201
  • 12
  • 49
  • 67
  • 5
    You can also install VSCodium (https://github.com/VSCodium/vscodium/releases) alongside, which is the real open-source version of VSCode, without the tracking/telemetry data collected by Microsoft. I use VSCode (with telemetry disabled) for viewing/editing general text/json/xml/sql files and VSCodium as the main IDE for golang and by doing so, I don't mix workspaces and single opened files with VSCode. – Edenshaw Dec 05 '19 at 13:57
  • 2
    Just to clarify what @Edenshaw mentioned. VSCodium is not what VSCode is based upon. "This is a repository of scripts to automatically build Microsoft's vscode repository into freely-licensed binaries with a community-driven default configuration." So it's basically just VSCode modified to remove the telemetry. I misunderstood for a second on thought that this comment was saying VSCode is a based off of a different open-source project like Chrome vs Chromium. – Keith Banner Mar 10 '20 at 20:14
  • 1
    This is not a good solution for having it open in the same workspace. See Mike Glenn's answer for a better and simpler approach – cavalcantelucas Oct 23 '20 at 21:37
  • See also: [Visual Studio Code open tab in new window](https://stackoverflow.com/questions/43362133/visual-studio-code-open-tab-in-new-window/43362800#43362800) – Gabriel Staples Oct 15 '21 at 00:45
119

Use

code -n

when launching the program. This "Opens a new session of Visual Studio Code instead of restoring the previous session." (from here).

The way I used this was by modifying my "Code" shortcut to include the -n parameter:

Visual Studio Code Shortcut

If it does not work, restart VSCode

Oranit Dar
  • 1,539
  • 18
  • 17
Matt Klein
  • 7,856
  • 6
  • 45
  • 46
  • 3
    On MacOS this just opens the same session. this did it for me: `while Ctrl+K then release the keys and press O would open the current tab in a new window` – RudyOnRails Feb 06 '19 at 15:50
75

Ctrl + Shift + P Duplicate Workspace in New Window Enter

from: https://code.visualstudio.com/updates/v1_24#_duplicate-workspace-in-new-window

Mike Glenn
  • 3,359
  • 1
  • 26
  • 33
  • 3
    Surprised how simple it is! No extension, no additional settings. Googled many answers but VSCode still reuses the existing window when opening the same directory. This answer finally did the trick! – Shawn Jun 19 '20 at 20:19
  • this works wayyy better for me; the newest version of vsc (1.52.1 at time of writing) if you try to open with control shift n or via the terminal on with "code -n" on the exact same folder this doesn't duplicate (vsc or the windows os is "smart" and just brings the previous window back into context). this way works way better :) – samuelsaumanchan Jan 06 '21 at 23:53
  • This is the one i was looking for – Lucas Rahn Dec 14 '21 at 08:07
  • This is exactly what I needed, should be voted up way more or even selected as THE answer to the original question. – user12147861 May 11 '22 at 07:03
  • Couldn't edit the original answer due to queue being full. Just wanted to add reference to new mac users, use cmd+shift+p for mac, and then search for Duplicate Workspace options – Subhash Dike May 27 '22 at 10:07
35

Select menu FileNew Window from the menu and then open the other folder in the new window.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
lex82
  • 11,173
  • 2
  • 44
  • 69
19

If you want to open multiple instances of the same folder, then it is not currently supported. Watch and upvote this GitHub issue if you want to see it implemented: Support to open a project folder in multiple Visual Studio Code windows

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ryan Walls
  • 6,962
  • 1
  • 39
  • 42
  • 3
    If you want to drag tabs off into their own floating windows, watch and upvote this github issue: https://github.com/Microsoft/vscode/issues/10121 – Roy Tinker Feb 01 '18 at 19:31
  • 4
    [This comment on a github issue](https://github.com/Microsoft/vscode/issues/2686#issuecomment-441350180) shows you how you can duplicate a workspace, which is what I was looking for. It is possible to use this to open multiple windows of Visual Studio Code in the same folder. Use the ["Duplicate Workspace in New Window"](https://code.visualstudio.com/updates/v1_24#_duplicate-workspace-in-new-window) command. – jrh Apr 16 '20 at 14:00
15

In Windows

  1. Press "Ctrl + Shift + P"
  2. Move the cursor to the line "Workspaces: Duplicate As Workspace in New Window".
  3. Click the setting icon on the line to configure the keybinding.
  4. Assign "Ctrl + Alt + D" (or other keys as you like) to this command.
  5. Use "Ctrl + Alt + D" to open multiple instances.
Quang Nguyen
  • 155
  • 1
  • 5
9

In case you are using VS Code for multiple purposes ( C#, Python, Database client, etc.), it's useful to separate each one instances in taskbar with different colors and themes.

To getting that you can use combination of these techniques:

Final Result:

enter image description here

HamedH
  • 2,814
  • 1
  • 26
  • 37
  • I just wanted to thank you because this is the problem I was looking to solve when I searched running multiple instances of visual studio code side by side – user254694 Oct 14 '21 at 12:00
  • **Portable mode**! That's what it's called if you want to have multiple instances with different extensions installed. Thanks for sharing. – SePröbläm Nov 11 '21 at 12:05
  • On Windows 10, how can I have multiple, auto-updating portable versions that share the same settings and extensions, have separate (not grouped) taskbar icons, have differently colored taskbar icons, and where I don't have to repeat any of these steps every time an update is installed? – still_dreaming_1 Mar 13 '23 at 11:52
8

I like opening Visual Studio Code from the run prompt/dialog instead, with a sweet and simple cmd /c code -n. Since the run dialog also maintains your command history on a per user basis, it is very convenient. One click and go -

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
RBT
  • 24,161
  • 21
  • 159
  • 240
6

Easiest when you don't know the CTRL+SHIFT+N shortcut is to use the menu: File, New Window

enter image description here

prosti
  • 42,291
  • 14
  • 186
  • 151
6

I came here to find out how to make VSCode (Mac OS) create a new window when a file or folder is opened and VSCode is already running. The same as GitHub Atom does. The answers above haven't answered my query, bit I've found answer myself so will share.

Setting: window.openFilesInNewWindow - if set to on, files will open in a new window. window.openFoldersInNewWindow - if set to on, folders will open in a new window.

Bonus to make it behave like Atom: Set window.newWindowDimensions to maximised.

Mere Development
  • 2,439
  • 5
  • 32
  • 63
4

You can also create a shortcut with an empty filename

"%LOCALAPPDATA%\Local\Code\Code.exe" ""
Todd Smith
  • 17,084
  • 11
  • 59
  • 78
3

Multiple instances of the same project

WORKAROUND

You cannot open multiple instances of the same folder but a workaround I have found is to open different folders.

lib
-components
-models
-helpers
tests

So, here I might open components, models and tests in different windows and then I can view them on my three monitors.

It sounds a bit simple but this has helped me a lot.

atreeon
  • 21,799
  • 13
  • 85
  • 104
3

You can open multiple windows (from the menu or by running the code executable again).

However, unfortunately there seems to be no way to actually have separate instances at the moment. For example, if you have two shells open with different environments in each (different paths, etc.), launching code for both will result in the second window sharing the same paths as the first, and ignoring the environment it was launched from.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

Starting with our 0.9.0 release, we added a new setting window.reopenFolders to control if Visual Studio Code should restore all folders of the previous session.

By default only the last active window you worked on will be restored, but if you change this setting to all, Visual Studio Code will reopen all folders in their windows automatically.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Benjamin Pasero
  • 113,622
  • 14
  • 75
  • 54
2

To open a new instance with your project loaded from terminal, just type code <directory-path>

nlt
  • 555
  • 7
  • 11
2

Multiple VS Code windows can be opened on the same effective folder if each opens the folder through a different path. For example, on Windows, a project in C:\Git\MyProject could be open in one instance of VS Code, while \MyPC\c$\Git\MyProject is open in another instance. If the admin share (c$) isn't available or suitable, an explicit share can be constructed that provides the necessary access.

No, this isn't an ideal solution.

Rich Armstrong
  • 143
  • 1
  • 7
2

In 2019, it will automatically open a new session, new instance of vs-code. By type

      C:\Apache24\htdocs\json2tree>code .

at the command window, under your project root folder.

first cd into your project folder,

        C:\Apache24\htdocs\json2tree>

then, type

         code .
hoogw
  • 4,982
  • 1
  • 37
  • 33
1

In Linux (tested with Ubuntu and Kali Linux) you can also right click the tile on the dock and select New Window.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rev
  • 1,213
  • 2
  • 11
  • 17
1

On Linux you can run it with the --user-data-dir parameter
I'm using the VSCodium version, therefore it has a different name but it should also work for the standard version

I copied the config from ~/.config/VSCodium to a new folder VSCodium2
and can now run a second instance of codium:

codium --user-data-dir ~/.config/VSCodium2

I've also created a new .desktop file: /usr/share/applications/VSCodium2.desktop
In there I had to change the Name and Exec property to launch VSCodium2

With these settings I can run the multiple instances with my launcher

Apart from the .desktop file and the locations, all of this should also work for Windows and Mac

enter image description here

linuxistsuper
  • 487
  • 4
  • 6
0

If you have all your JavaScript files in multiple folders under one folder that works out very well, and that's what I did:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

My easiest trick is to just duplicate the .code-workspace file you are using for your workspace and you can essentially trick VSCode to have two separate windows.

Although if you want to synchronize the the settings, you will have to sync the two files. In Windows 10/11 you can use an elevated command prompt (not Powershell) and make a hard link using mklink /H Link Target.

I've tried using a symbolic link but it just tries to reopen the target. With a hard link you can modify the workspace settings and have them synched together!

StickySli
  • 81
  • 8