【发布时间】:2016-09-15 08:33:55
【问题描述】:
【问题讨论】:
-
请编辑这篇文章,以便它提出问题。目前无法决定要支持哪些答案,因为我不知道哪些答案正确地回答了(假设的)问题。
标签: windows-7 visual-studio-code windows-7-x64
【问题讨论】:
标签: windows-7 visual-studio-code windows-7-x64
复制自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\""
双击它以创建注册表项。
如果“使用代码打开”没有出现在资源管理器的上下文菜单中,那么您应该重新启动系统。
如果您运行的是 64 位或 Insiders 版本的 VS Code,请相应地更改路径。
【讨论】:
注意:这适用于 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
【讨论】:
这些设置通常为 VS Code 的每个用户存储。
要设置新用户帐户:重新运行安装程序。
【讨论】:
我想补充一点,很多人喜欢使用 Registry 方法,因为他们担心他们可能会丢失所有设置。只需重新下载(如果您还没有下载文件)并重新安装。重装时打勾
Add "Open with Code" action to Windows Explorer file context menu
Add "Open with Code" action to Windows Explorer directory context menu
正如在其他答案中所说。您的设置将保持不变。事实上,当它启动时,它会与您的工作目录一起启动,就好像您从未卸载过它一样。
【讨论】:
这是 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\""
【讨论】:
这个问题通常发生在 vs code 用户具有标准用户角色的情况下。在 VS Code 安装时弹出管理员提示,这意味着 VS Code 以管理员用户身份安装。如果您勾选了这些框,则会添加快捷方式,但仅适用于安装时在管理员提示符中键入的管理员帐户。
快速解决方法是将当前用户(将使用 vs 代码)临时添加到管理员组,卸载然后使用当前用户管理员权限再次安装 VS Code,并在安装后将用户从管理员组中删除。
【讨论】:
我在 64 位 VS 代码的早期版本中遇到了同样的问题。即使在我通过检查上述选项重新安装后它也不起作用。
我已经安装了代码v1.25.0的最新更新,问题自动修复了。
请找到 64 位 regedit 修复程序 here。
【讨论】:
以上注册表项均不适用于标准(非管理员)用户帐户。
然后我将所有密钥插入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\""
【讨论】:
我的 vscode 安装在这里:
C:\Users\saber\AppData\Local\Programs\Microsoft VS Code\code.exe
应将 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\\
【讨论】:
如果您已经安装了 vscode,并且想要“使用代码打开”选项。
只需从官网下载vscode... here!
选中“使用代码打开”选项运行安装程序。
它将使用“使用代码打开”选项更新现有的 vscode 安装。
【讨论】:
只需再次运行安装程序并选择open in file explorer 选项。一切就绪。
不用担心已经在 vsCode 中打开的文件,它们都不会改变
【讨论】:
尝试找出 Microsoft vs Code 文件,它在默认位置有一段时间,有时在 C:\Users\PAPPU KUMAR\AppData\Local\Programs\Microsoft VS Code。
然后将其添加到 vscode.reg(create one) 文件中。
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,然后右键打开文件所在位置:
右键单击并单击属性,然后复制文件路径。
打开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://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
示例:
【讨论】:
只需重新运行安装程序并选择设置中的选项并安装即可。您不会丢失任何数据。一切都会像以前一样完好无损。它只是添加缺少的设置并更新路径。
【讨论】:
按照这些步骤,你一定会得到 - 在资源管理器中使用代码打开。
为什么你没有得到这个,因为你在安装时没有将它添加到 Visual Studio 代码中,备份你的项目,如果你有, 对于 Windows 用户,只需按照以下步骤操作:
从中卸载 Visual Studio Code。 控制面板\程序\程序和功能: image
重新安装 Visual Studio: 你在这里获取/下载:https://code.visualstudio.com/download
安装时,在选择附加任务处停止, 勾选打开选项 - 安装过程中可用的 2 个框, 完成安装: image
已完成,请在资源管理器中查看。您会在 explorer 中找到: image
你也可以,试试其他方法, 注册表编辑器 - 这很复杂 -
【讨论】:
我使用的是 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\""
【讨论】:
------------------简单的方法------------------
步骤 1. 卸载 VS 代码。
第 2 步。下载最新版本,在安装时您需要检查 open with vs code 选项。
根据官方 VS Code 问题: https://github.com/Microsoft/vscode/issues/42889#issue-294121388
【讨论】: