Dfr
Dfr

Reputation: 221

Add "Open with Visual Studio Code" shortcut to right click menu

Step 1: Open Run and Access the Registry Editor

Opening Registry Editor

Step 2: Navigate to the Following Directory in the Registry Editor

Navigate to Directory

Computer\HKEY_CLASSES_ROOT\Directory\Background\shell

Step 3: Create a New Key

Create New Key in Shell

Setting Up the Name and Icon of the Shortcut:

Values

Command:

Creating Command

Create a new key in your directory and set the "(Default)" value to the command.

This is not a question but rather a guide on how to add the "Open with Visual Studio Code" option to the right-click menu.

Upvotes: 20

Views: 16725

Answers (4)

Gray
Gray

Reputation: 11

If you not want/know edit regedit code, you can create/download file with extension .reg . Link for template .zip Content this file:

Windows Registry Editor Version 5.00

; Add "Open with Code" to the context menu for files/directory/directory background/drive.

[HKEY_CLASSES_ROOT\*\shell\VSCode]
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"
@="Open w&ith Code"

[HKEY_CLASSES_ROOT\*\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\shell\VSCode]
@="Open w&ith Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"

[HKEY_CLASSES_ROOT\Directory\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode]
@="Open w&ith Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""

[HKEY_CLASSES_ROOT\Drive\shell\VSCode]
@="Open w&ith Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe"

[HKEY_CLASSES_ROOT\Drive\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""

You need change Path to installed VSC on your PC...Example for first lines:

[HKEY_CLASSES_ROOT\*\shell\VSCode]
"Icon"="D:\\Soft\\Microsoft VS Code\\Code.exe"
@="Open w&ith Code"

You need launch this file with .reg extension and Agree change registry.

Upvotes: 1

Lasse Hamborg
Lasse Hamborg

Reputation: 237

This worked great, Thanks!

For dummies like me, I'll just elaborate on some dummy-steps:

  • If the "Icon" does not show up automatically (like I thought), create it by right-click -> New -> String Value in the open_vscode folder (as named in the example). Rename it Icon and paste the path to the exe file in quotations. Do not try to locate the actual icon file/png. 1
  • The path in the (Default) (in the subfolder command) should have a space after the path (in quotations) that say ".". This way, the very folder is opened. Otherwise, the command just opens VS Code but not in the directory. Hence my (Default) looks like: "C:\Program Files\Microsoft VS Code\Code.exe" "."

ADDITION:

In the name of the menu item, i.e. the value of the (Default), you can add a & sign before the letter that you want as a hotkey. E.g. Open with VS &Code will give me the C as a hotkey in the menu:

Notice the C in the menu item

Upvotes: 1

Abhijit Kumar
Abhijit Kumar

Reputation: 311

I installed through Microsoft Dev Preview, it didn't ask for any option and install it directly.

If you facing issue with where path is visible but correct directory not opening, put the command value as

C:\Users\abhijit\AppData\Local\Programs\Microsoft VS Code\Code.exe "%V"

where %V is selected directory

enter image description here

Upvotes: 0

codeBreak
codeBreak

Reputation: 81

For those who are new to the Registry Editor, here's an additional note for Step 3:

  1. Double-click on the (Default) key to open a popup.
  2. Enter your value there.

If you're entering "Open with Visual Studio Code," that's fine. However, if you're entering a path, remember to wrap your path in double quotes, as shown in the example above.

For instance, my icon value is:

"C:\Users\PACKARD BELL\AppData\Local\Programs\Microsoft VS Code\Code.exe"

And my command value in the command key is:

"C:\Users\PACKARD BELL\AppData\Local\Programs\Microsoft VS Code\Code.exe" .

Notice that with the command value here, we have the path wrapped in double quotes, as well as white space and a dot wrapped in double quotes.

Upvotes: 8

Related Questions