How to open your files with vs code from the context menu on Windows

matheusgomes062

Matheus Gomes 👨‍💻

Posted on May 28, 2020

How to open your files with vs code from the context menu on Windows

Hello!

How long it's been since I posted some content? I think about 3 months or so. But hey, here I'm again, with a new thing I learned.

I was on a quest to open a file with vs code and wanted to make it easy and simple, it was when I thought, why not open it from the context menu? For those who don't know, the context menu is the little menu that opens when you click with the right button of the mouse on some empty space of the folder. There you can access some easy features.

Now let's learn how to place your vs code there!

First, I must say, when you are installing vs code you are presented with the option to make it open in the context menu. So if you are installing it now, you can just mark those boxes and you are done!

For those of you who didn't check it when installing, follow me.

First, you will need to create a .reg file, before you freak out, a .reg file is a 'Windows Register File', The Windows Registry is a hierarchical database where Windows and many applications store configuration settings. So, in order to change some configuration on the context menu, we need to make a .reg file.

In this case, we create a .reg file and open it with some text editor (you can use vs code for this). With it open, we need to place this text:



Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Program Files\\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:\\Program Files\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Program Files\\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:\\Program Files\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""


Enter fullscreen mode Exit fullscreen mode

You can see the default installation folders path are placed in the text, if you have another folder in which you installed the vs code, you just need to replace it in the text. Mine was different:



C:\\Users\\mathe\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe


Enter fullscreen mode Exit fullscreen mode

After that, save and double click the file, it will ask you for permissions, you accept accordingly and here we have, a vs code option on the context menu on Windows!

Hope you enjoyed as much as me! Until next time!!

Useful Links that helped me to create this:

💖 💪 🙅 🚩
matheusgomes062
Matheus Gomes 👨‍💻

Posted on May 28, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related