How do I open multiple instances of Visual Studio Code?

Visual Studio-Code

Visual Studio-Code Problem Overview


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?

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

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.

+ Shift + N and + K for Mac.

List of helpful keyboard shortcuts can be found here.

Solution 2 - Visual Studio-Code

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

Solution 3 - Visual Studio-Code

Ctrl + Shift + P Duplicate Workspace in New Window Enter

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

Solution 4 - Visual Studio-Code

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

Solution 5 - Visual Studio-Code

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

Solution 6 - Visual Studio-Code

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

Solution 7 - Visual Studio-Code

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

Solution 8 - Visual Studio-Code

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.

Solution 9 - Visual Studio-Code

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.

Solution 10 - Visual Studio-Code

You can also create a shortcut with an empty filename

"%LOCALAPPDATA%\Local\Code\Code.exe" ""

Solution 11 - Visual Studio-Code

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.

Solution 12 - Visual Studio-Code

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.

Solution 13 - Visual Studio-Code

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

Solution 14 - Visual Studio-Code

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.

Solution 15 - Visual Studio-Code

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.

Solution 16 - Visual Studio-Code

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

enter image description here

Solution 17 - Visual Studio-Code

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 .

Solution 18 - Visual Studio-Code

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

Solution 19 - Visual Studio-Code

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

Solution 20 - Visual Studio-Code

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

Solution 21 - Visual Studio-Code

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!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBinary WorrierView Question on Stackoverflow
Solution 1 - Visual Studio-CodeBlake MumfordView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeMatt KleinView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeMike GlennView Answer on Stackoverflow
Solution 4 - Visual Studio-Codelex82View Answer on Stackoverflow
Solution 5 - Visual Studio-CodeRyan WallsView Answer on Stackoverflow
Solution 6 - Visual Studio-CodeRBTView Answer on Stackoverflow
Solution 7 - Visual Studio-CodeHamedHView Answer on Stackoverflow
Solution 8 - Visual Studio-CodeQuang NguyenView Answer on Stackoverflow
Solution 9 - Visual Studio-CodeMere DevelopmentView Answer on Stackoverflow
Solution 10 - Visual Studio-CodeTodd SmithView Answer on Stackoverflow
Solution 11 - Visual Studio-CodeatreeonView Answer on Stackoverflow
Solution 12 - Visual Studio-CodeBenjamin PaseroView Answer on Stackoverflow
Solution 13 - Visual Studio-CodenltView Answer on Stackoverflow
Solution 14 - Visual Studio-Codeplease delete meView Answer on Stackoverflow
Solution 15 - Visual Studio-CodeRich ArmstrongView Answer on Stackoverflow
Solution 16 - Visual Studio-CodeprostiView Answer on Stackoverflow
Solution 17 - Visual Studio-CodehoogwView Answer on Stackoverflow
Solution 18 - Visual Studio-CodeRevx0rView Answer on Stackoverflow
Solution 19 - Visual Studio-CodelinuxistsuperView Answer on Stackoverflow
Solution 20 - Visual Studio-CodeKai CriticallyAcclaimed CooperView Answer on Stackoverflow
Solution 21 - Visual Studio-CodeStickySliView Answer on Stackoverflow