vs_code

I’m a huge fan of Microsoft’s Visual Studio Code but the one thing that I found was missing when switching from Sublime Text is the inability to open any file with it by using the context menu.

Adding this functionality can be done with a simply registry tweak.

  1. Open the registry by pressing [WIN]+[R} and typing regedit
  2. Navigate to HKEY_CLASSES_ROOT\*\shell and add a key with the text you want to appear in the context menu. For example: “Open with VS Code”
  3. Create a new key inside this called “command”
  4. Modify the default value in “command” to C:\Program Files (x86)\Microsoft VS Code\Code.exe "%1".
  5. To clean up the context menu listing a bit, modify the (Default) key in the Open with VS Code folder to Edit with VS Code then add an Icon Key by right clicking and selecting New > String Value and adding the following as the value. C:\Program Files (x86)\Microsoft VS Code\Code.exe,0

Follow the steps below to handle opening folders as projects. This is especially helpful when searching through misc code without having to open it up in a full fledged IDE. This is exceptionally helpful when working with more complicated scripting projects such as Python.

  1. Navigate to [KHEY_CLASSES_ROOT\Directory\shell
  2. Create a key and name it vscode.
  3. Add the text and icon information by doing the same as above by modifying the default string to Open Folder as VS Code Project and adding an Icon string targeting "C:\Program Files (x86)\Microsoft VS Code\Code.exe",0
  4. To properly target VS Code, add a new code under the new vscode folder and name it “command” and adding the following to the default string "C:\Program Files (x86)\Microsoft VS Code\Code.exe" "%1"
  5. To support opening the current folder by right-clicking in the white space inside Windows Explorer, navigate to [HKEY_CLASSES_ROOT\Directory\Background\shell
  6. Create another folder called “vscode”
  7. Change the default string to Open Folder as VS Code Project
  8. Add a new string, name it “Icon” with the value "C:\Program Files (x86)\Microsoft VS Code\Code.exe",0

As an alternative, you can copy the below code into an empty text file and rename it as vscode.reg and then run it by double clicking.

3 thoughts on “Adding Visual Studio Code to Your Context Menu

  1. For opening in whitespace background make sure to add the command using %V and not %1. Additionally, playing around with quotations fixed this for me & expandable string values for Icon.

  2. Useful, thank you. It is worth noting that you have to check the installation path of vscode, right now, if you install it from the windows store it is located in the appdata folder.

Leave a Reply

Your email address will not be published. Required fields are marked *