右键单击文件夹后,Visual Studio代码"打开代码"不会出现

Der*_*rek 61 windows-7 windows-7-x64 visual-studio-code

刚刚在Windows 7计算机上安装了Visual Studio Code 1.1.1.当我右键单击文件夹时,"Open With Code"不会出现.

在此输入图像描述

Wos*_*osi 87

复制自http://thisdavej.com/right-click-on-windows-folder-and-open-with-visual-studio-code/

  • 使用此内容创建文件vsCodeOpenFolder.reg(如果未选择默认安装路径,则需要调整此文件中的路径):

    Windows Registry Editor Version 5.00
    ; Open files
    [HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
    @="Edit with VS Code"
    "Icon"="C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe,0"
    [HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
    @="\"C:\\Program Files (x86)\\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 (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\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 (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""
    
    Run Code Online (Sandbox Code Playgroud)
  • 双击它以创建注册表项

  • 如果"使用代码打开"未显示在资源管理器的上下文菜单中,则应重新启动系统.
  • 如果您正在运行VS代码的64位或内部版本,请相应地更改路径

  • @wosi 如果需要的话我们如何删除该选项? (7认同)
  • 现在 64 位代码已可用,将所有出现的“(x86)”替换为“”也同样有效。或者换句话说,将“Program Files (x86)”更改为“Program Files”。 (4认同)
  • 我从来没有能够在用户帐户下工作.但它适用于管理员帐户. (2认同)
  • 对于那些将其转移到其他用例的人:上下文菜单“HKEY_CLASSES_ROOT\Directory\shell\vscode”和“HKEY_CLASSES_ROOT\Directory\Background\shell\vscode”之间的区别是您单击某个目录还是“无”(你总是在 win explorer 的目录中) (2认同)
  • 即使给定的源代码也声明“简单地重新安装 VS Code 更容易。”:这些选项位于安装过程中 (2认同)

Ana*_*yst 41

就我而言,我只是重新运行 vscode 设置并将所有复选框标记为已选中并且它有效。在此输入图像描述

  • 这正是推荐的方法。 (3认同)

was*_*mup 36

安装(或重新安装)时,特别检查所有复选框:

在Windows资源管理器文件上下文菜单中
添加"打开代码"操作将"打开代码"操作添加到Windows资源管理器目录上下文菜单

安装vscode

我希望这有帮助.

  • 好处是您可以简单地安装它,无需先卸载! (5认同)
  • 我重新激活了一个已有 11 年历史的堆栈交换帐户以对此进行投票 (3认同)
  • 重新安装并确保检查选项-已为我修复 (2认同)

Tho*_*ban 18

以下是Cockney Rhyming Jedi在适用于64位版 Visual Studio Code 之前提供的文件版本:

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

  • @JonSnow,您可以简单地将 @= 之后的文本更改为您喜欢的任何内容。您可以说 @="用 JonSnow 的编辑器打开",而不是 @="以 VS Code 项目方式打开文件夹" ..lol (2认同)

Coc*_*edi 12

注意:这是针对32位版本,对于64位版本,请参阅Cepharum的回答.

稍微更改上一个答案,以允许非管理员在其上下文菜单中获取功能:

  • 使用此内容创建文件vsCodeOpenFolder.reg(如果未选择默认安装路径,则需要调整此文件中的路径):

    Windows Registry Editor Version 5.00
    ; Open files
    [HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code]
    @="Edit with VS Code"
    "Icon"="C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe,0"
    [HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command]
    @="\"C:\\Program Files (x86)\\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_CURRENT_USER\Software\Classes\Directory\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\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_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0
    [HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""
    
    Run Code Online (Sandbox Code Playgroud)
  • 双击它以创建注册表项

  • 如果"使用代码打开"未显示在资源管理器的上下文菜单中,则应重新启动系统.

基本上我已经用HKEY_CURRENT_USER\Software\Classes替换了HKEY_CLASSES_ROOT


sab*_*zdi 10

我的 vscode 安装在这里:

C:\Users\saber\AppData\Local\Programs\Microsoft VS Code\code.exe
Run Code Online (Sandbox Code Playgroud)

应该用你的电脑用户名替换 SABRE

在此处输入图片说明

所以脚本是这样的:

将此内容保存为 .reg 脚本文件,第一行Windows 注册表编辑器版本 5.00

然后运行它:

Windows Registry Editor Version 5.00

; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\saber\\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\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\saber\\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\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\saber\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""
Run Code Online (Sandbox Code Playgroud)

将 Visual Studio 代码添加到 Windows 中的右键单击文件夹

更换\\saber\\\\YOUR_PC_USER_NAME\\


Nei*_*rao 9

None of the registry entries above worked for me with a standard (non-admin) user account.

I then inserted all the keys into HKEY_LOCAL_MACHINE and then it worked!

Windows Registry Editor Version 5.00

; when you right click a file
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\VSCode]
@="Open with Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"

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

; when you right click a folder
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VSCode]
@="Open Folder in Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

; when you right click a folder while holding shift
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\VSCode]
@="Open Folder in Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"

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

; when you right click the background, not on a particular file or folder.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\LibraryFolder\Background\shell\VSCode]
@="Open Folder in Code"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\LibraryFolder\Background\shell\VSCode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""
Run Code Online (Sandbox Code Playgroud)


Ric*_*ard 8

对于VS Code,这些设置通常按用户存储.

要设置新用户帐户:重新运行安装程序.


Alf*_*Moh 7

我想补充一点,很多人都希望使用Registry方法,因为他们担心他们可能会放弃所有设置.只需重新下载(如果您还没有下载文件)并重新安装.重新安装时,勾选

Add "Open with Code" action to Windows Explorer file context menu
Add "Open with Code" action to Windows Explorer directory context menu
Run Code Online (Sandbox Code Playgroud)

正如其他答案中所述.您的设置将保持不变.事实上,当它启动时,它会与您的工作目录一起启动,就像您从未卸载它一样.

  • 这对我来说效果很好,是的 - 正如你提到的,所有设置扩展都保持不变! (2认同)

Adi*_*aik 7

如果你已经安装了 vscode 并且你想要“用代码打开”选项。

只需从官方网站下载vscode... 这里

在选中“使用代码打开”选项的情况下运行安装程序。

它将使用“用代码打开”选项更新现有的 vscode 安装。


Sal*_*lli 7

如果您使用的是Windows 11,不想搞乱注册表,也不想等待下一次更新,只需按住Shift 键右键单击文件夹或文件即可。


sud*_*tin 6

如果您更喜欢使用键盘而不是鼠标。该解决方案适合您...

在文件资源管理器(位置)中键入以下命令。

打开一个项目

vscode://file/{full path to project}/

vscode://file/c:/myProject/

vscode:// --opens vscode for current directory
Run Code Online (Sandbox Code Playgroud)

打开文件

vscode://file/{full path to file}

vscode://file/c:/myProject/package.json
Run Code Online (Sandbox Code Playgroud)

打开文件到行和列

vscode://file/{full path to file}:line:column

vscode://file/c:/myProject/package.json:5:10
Run Code Online (Sandbox Code Playgroud)

来源https : //code.visualstudio.com/docs/editor/command-line

例子:

在此处输入图片说明


小智 5

只需open in file explorer选择选项再次运行安装程序。你会准备好。

不用担心vsCode中已经打开的文件,一个都不会改


小智 5

粘贴下面的代码并使用.reg扩展名保存

Windows Registry Editor Version 5.00 ; Open files

[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code] @="Edit with VS Code" 

"Icon"="C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe,0" 

[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command] 

@="\"C:\Users\hp\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_CURRENT_USER\Software\Classes\Directory\shell\vscode] 
@="Open Folder as VS Code Project"

"Icon"="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe",0"

[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]

@="\"C:\Users\hp\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_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]

@="Open Folder as VS Code Project"

"Icon"="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe",0

[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]

@="\"C:\Users\hp\AppData\Local\Programs\Microsoft VS Code\Code.exe" \"%V\""
Run Code Online (Sandbox Code Playgroud)

然后按Windows键,找到 Visual Studio Code,然后右键单击并打开该位置的文件:

打开vscode位置

右键单击并单击Properties,然后复制文件路径。

在此输入图像描述

打开regedit

注册表编辑

对于以下各项,双击图标,然后粘贴您从上面复制的文件路径:

[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code]
[HKEY_CURRENT_USER\Software\Classes\*\shell\Open with VS Code\command]
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode]
[HKEY_CURRENT_USER\Software\Classes\Directory\shell\vscode\command]
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode]
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\vscode\command]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述