Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open folder in new vs code instance by right clicking on the folder?

I have open two folders inside a VS Code instance.

For example (folder name): A and B

I want to open the folder B in a new instance of VS Code, but there is no option to open by right-clicking on the folder.

enter image description here

Even Atom has the option to open the folder in a new instance.

enter image description here

like image 752
Yashu Mittal Avatar asked Jul 03 '18 10:07

Yashu Mittal


People also ask

How do I open a folder directly with Visual Studio Code?

On the Visual Studio menu bar, choose File > Open > Folder, and then browse to the code location. On the context (right-click) menu of a folder containing code, choose the Open in Visual Studio command. Choose the Open Folder link on the start window.

How do you add right click open with VS Code?

How do I add program to open with right-click menu? Adding a new program for a file to open is is done from the right-click menu when selecting the file. Choose “Open with” to open an additional window with more options. Find a new program from the “Browse” button and select the proper executable.

How do I open a folder directly in Visual Studio Code by right clicking in Windows Explorer?

Often, we need to open folder in Visual Studio Code in order to run a project. So it's easy if there is an option to open any folder directly in Visual Studio Code from Windows Explorer. We can do it by changing "Right Click Context Menu" registry.


3 Answers

This extension allows you to open a folder in a new vscode window.
Open Folder Context Menus for VS Code

like image 128
Dan Avatar answered Oct 03 '22 19:10

Dan


You can go via File > New window or ctrl+shift+n for a new window, and open the second folder there.

Or the "window.openFoldersInNewWindow" setting:

// Controls if folders should open in a new window or replace the last active window.
// - default: folders will open in a new window unless a folder is picked from within the application (e.g. via the File menu)
// - on: folders will open in a new window
// - off: folders will replace the last active window
// Note that there can still be cases where this setting is ignored (e.g. when using the -new-window or -reuse-window command line option).
"window.openFoldersInNewWindow": "default",
like image 34
katsho Avatar answered Oct 03 '22 17:10

katsho


Create a registry File e.g. OpenOnRightClick.reg

Add these lines to the file:

Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click INSIDE a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="Open Folder as VS Code Project"
"Icon"="\"C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""

Change the location of visual studio code as per your installation directory Now just double click on the OpenOnRightClick.reg file, confirm if asked ! All done ! on you right click you will have a open with Code option.

like image 23
Manish S Avatar answered Oct 03 '22 19:10

Manish S