答案 0 :(得分:78)
从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\""
双击它以创建注册表项
答案 1 :(得分:33)
安装(或重新安装)时,特别检查所有复选框:
添加"打开代码"操作到Windows资源管理器文件上下文菜单
添加"打开代码"对Windows资源管理器目录上下文菜单的操作
我希望这会有所帮助。
答案 2 :(得分:11)
注意:这是针对 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\""
双击它以创建注册表项
基本上我已将HKEY_CLASSES_ROOT替换为HKEY_CURRENT_USER \ Software \ Classes
答案 3 :(得分:6)
我的vscode安装在这里:
C:\Users\saber\AppData\Local\Programs\Microsoft VS Code\code.exe
应使用您的PC用户名替换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\""
将Visual Studio代码添加到Windows中的右键单击文件夹
将\\saber\\
替换为\\YOUR_PC_USER_NAME\\
答案 4 :(得分:5)
我想补充一点,很多人都希望使用Registry方法,因为他们担心他们可能会放弃所有设置。只需重新下载(如果您还没有下载文件)并重新安装。重新安装时,勾选
{{1}}正如其他答案中已经说过的那样。您的设置将保持不变。实际上,当它启动时,它会与您的工作目录一起启动,就像您从未卸载它一样。
答案 5 :(得分:5)
上面的注册表项都不适合我使用标准(非管理员)用户帐户。
然后我将所有密钥插入HKEY_LOCAL_MACHINE
中,然后它起作用了!
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\""
答案 6 :(得分:4)
如果您更喜欢使用键盘而不是鼠标。此解决方案适合您...
在文件浏览器(位置)中键入以下命令。
打开项目
vscode://file/{full path to project}/
vscode://file/c:/myProject/
vscode:// --opens vscode for current directory
打开文件
vscode://file/{full path to file}
vscode://file/c:/myProject/package.json
打开要在行和列中显示的文件
vscode://file/{full path to file}:line:column
vscode://file/c:/myProject/package.json:5:10
来源:https://code.visualstudio.com/docs/editor/command-line
示例:
答案 7 :(得分:3)
只需在选择open in file explorer
选项的情况下再次运行安装程序即可。一切准备就绪。
不用担心已经在vsCode中打开的文件,它们都不会被更改
答案 8 :(得分:2)
如果您已经安装了vscode,并且想要“使用代码打开”选项。
只需从官方网站下载vscode ... here!
运行安装程序,并选中“使用代码打开”选项。
它将使用“使用代码打开”选项更新现有的vscode安装。
答案 9 :(得分:2)
答案 10 :(得分:2)
我使用了 64 位 VS Code 安装程序
<块引用>将此代码复制并粘贴到您的电脑记事本中
<块引用>另存为 vscode.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\\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 handle right clicking on a folder and open that folder
; as a new project
[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 handles the case of right clicking inside of a folder
; to open that folder as a new project
[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\""
答案 11 :(得分:1)
尝试找出Microsoft vs Code文件是在默认位置,但是有时在C:\ Users \ PAPPU KUMAR \ AppData \ Local \ Programs \ Microsoft VS Code中。
,然后将其添加到vscode.reg(创建一个)文件中。
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\PAPPU KUMAR\\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\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\PAPPU KUMAR\\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\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\PAPPU KUMAR\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""
答案 12 :(得分:1)
粘贴以下代码,并保存为 .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\""
然后按 Windows 键,找到Visual Studio Code,然后右键单击并打开文件位置:
右键单击并单击属性,然后复制文件路径。
打开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]
答案 13 :(得分:1)
只需重新运行安装程序并在安装程序中选择选项,然后进行安装即可。您不会丢失任何数据。一切将保持原样。它只是添加缺少的设置并更新路径。
答案 14 :(得分:0)
当vs代码用户具有标准用户角色时,通常会发生此问题。在VS Code安装上,弹出管理员提示符,表示vs代码以admin用户身份安装。如果勾选方框,则会添加快捷方式,但仅应用于安装时输入管理员提示的管理员帐户。
快速解决方法是将当前用户(将使用vs代码)临时添加到管理员组,卸载然后使用当前用户管理员权限再次安装VS Code,并在安装后从admin组中删除该用户。 / p>
答案 15 :(得分:0)
按照以下步骤操作,您将肯定会得到-在资源管理器中打开代码。
为什么没有得到这个,因为安装时没有将其添加到Visual Studio代码中,备份项目,如果有的话, 母鸡请按照以下步骤操作对于Windows用户:
卸载Visual Studio Code From。 控制面板\程序\程序和功能: image
重新安装Visual Studio: 在这里您可以获取/下载:https://code.visualstudio.com/download
在安装时,在选择其他任务处停止, 勾选并打开选项-2个框,在安装过程中可用, 完成安装: image
已完成,请在资源管理器中检查。您将在资源管理器中找到: image
您也可以尝试其他方法, 注册表编辑器-很复杂-
答案 16 :(得分:0)
答案 17 :(得分:-1)