While installing the VS Code, we get an option to tick for Open with Code
. I gave the tick mark for only files but not for folders. So how to turn it on after installation?
When I'm opening a file:
When I'm opening a folder :
I want the Open with Code
option on right-click in the folder just like it shows on files.
Save this contents to a new .reg
file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\VSCode]
@="Open with Code"
"Icon"="\"%LocalAppData%\\Programs\\Microsoft VS Code\\Code.exe\""
[HKEY_CLASSES_ROOT\Directory\shell\VSCode\command]
@=hex(2):22,00,25,00,4c,00,6f,00,63,00,61,00,6c,00,41,00,70,00,70,00,44,00,61,\
00,74,00,61,00,25,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,00,\
5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,20,00,56,00,53,\
00,20,00,43,00,6f,00,64,00,65,00,5c,00,43,00,6f,00,64,00,65,00,2e,00,65,00,\
78,00,65,00,22,00,20,00,22,00,25,00,56,00,22,00,00,00
Run the file and that's it.
The answer from @dqureshiumar is correct, if you already checked that option during VS Code installation. But maybe you haven't checked it and don't want or can't reinstall it right now. Or maybe you just need more flexibility about the actions shown when right clicking a folder.
So of course we have a lot of people in comments and/or in other answers here talking about how easy it's to run the installer again. Yes, it is! Just use this solution if you want to do by hand what the installer will do for you, or use this solution as a learning opportunity to understand better how Windows manage context menu actions on directories, to be able to customize what you want for other use cases.
Dealing with regedit
can be dangerous. Use it with caution and create a .reg
backup before starting if you're not so experienced on it.
So you are able to create your own folder actions at the Windows Registry:
regedit
.HKEY_CLASSES_ROOT\Directory\shell
.Key
named vscode
.(Default)
REG_SZ
, put the desired text, like Open with Code
.Icon
key pointing to the Code.exe
path (most likely "C:\Users\%UserName%\AppData\Local\Programs\Microsoft VS Code\Code.exe"
).At this point, something like this:
Yet inside regedit
, go ahead:
Key
named command
inside the vscode
one.(Default)
REG_SZ
, put the action to open the current path ("%V"
) based on your Code.exe
path (most likely "C:\Users\%UserName%\AppData\Local\Programs\Microsoft VS Code\Code.exe" "%V"
).Now, see something like this:
Finally, go ahead to Windows Explorer and right click any folder:
It's updated on demand, so you can also play with text, icon and command to try your own custom actions, if you want. The VS Code Command Line Interface reference could be helpful if you want to play with another possibilites, like adding the clicked folder to the current Workspace.
If you try to "Open with Code" a folder from a different drive than your VS Code installation (most likely C:
), maybe you'll receive an error message starting with "You do not have permission to...". This is because a REG_SZ
record can be wrongly interpreted in cases it contains multiple strings inside the value. Unfortunately the Windows Registry Editor UI doesn't offer a way to convert REG_SZ
to REG_EXPAND_SZ
on (Default)
keys. If you face this problem, just use my TLDR solution with the hex(2)
value, which will automatically create the REG_EXPAND_SZ
type.
As Marc L. has already pointed out, reinstallation is the easiest way to activate Open with Code
. The reinstallation does not affect the settings and extensions you previously had.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With