刚刚在Windows 7计算机上安装了Visual Studio Code 1.1.1。当我右键单击一个文件夹时,不会出现“使用代码打开”。
Answers:
从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\""
双击以创建注册表项
这是由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\""
注意:这是针对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_CURRENT_USER \ Software \ Classes替换了HKEY_CLASSES_ROOT
上面的注册表项都不适合标准(非管理员)用户帐户使用。
然后,我将所有密钥插入其中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\""
我想补充一点,许多人希望使用Registry方法,因为他们担心会丢失所有设置。只需重新下载(如果您还没有下载文件)并重新安装。重新安装时,勾选
Add "Open with Code" action to Windows Explorer file context menu
Add "Open with Code" action to Windows Explorer directory context menu
正如其他答案中已经说过的。您的设置将保持不变。实际上,当它启动时,它将与您的工作目录一起启动,就好像您从未卸载过它一样。
我的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中的右键单击文件夹
只需open in file explorer
选择选项,再次运行安装程序。一切准备就绪。
不用担心在vsCode中已经打开的文件,它们都不会被更改
如果您更喜欢使用键盘而不是鼠标。该解决方案适合您...
在文件资源管理器(位置)中键入以下命令。
打开一个项目
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
例:
尝试找出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\""
粘贴下面的代码并以.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,然后右键单击并打开文件位置:
右键单击并单击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]
*.reg
文件>
位于每一行的开头,并且内容的包装方式相信会导致导入问题。此外,您的注册表路径确实不一致,有些>
甚至使用甚至-->
用作路径定界符。我已经对此进行了更新,以防止出现这些问题。请仔细检查我的更改,以确保它们能够抓住您的意图。不过,在将来,请更加注意格式和代码,以确保其有效。
如果您已经安装了vscode,并且想要“使用代码打开”选项。
只需从官方网站下载vscode ... 这里!
运行选中“用代码打开”选项的安装程序。
它将使用“使用代码打开”选项更新现有的vscode安装。
只需重新运行安装程序并在安装程序中选择选项,然后进行安装即可。您不会丢失任何数据。一切将保持原样。它只是添加缺少的设置并更新路径。