【问题标题】:How to open folder in new vs code instance by right clicking on the folder?如何通过右键单击文件夹在新的 vs 代码实例中打开文件夹?
【发布时间】:2018-07-03 10:11:19
【问题描述】:

我在 VS Code 实例中打开了两个文件夹。

例如(文件夹名):A和B

我想在 VS Code 的新实例中打开文件夹 B,但是没有选项可以通过右键单击该文件夹来打开。

甚至 Atom 也可以选择在新实例中打开文件夹。

【问题讨论】:

标签: visual-studio-code


【解决方案1】:

此扩展允许您在新的 vscode 窗口中打开文件夹。
Open Folder Context Menus for VS Code

【讨论】:

  • 如果一切都失败了,希望有一个扩展来解决差距/问题。感谢分享!
  • 祝福你的分享心。
【解决方案2】:

创建一个注册表文件,例如OpenOnRightClick.reg

将这些行添加到文件中:

Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\xx\\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\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Users\\xx\\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\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\",0"
[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Users\\xx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%V\""

根据您的安装目录更改 Visual Studio 代码的位置 现在只需双击 OpenOnRightClick.reg 文件,确认是否询问! 全部做完 !在您右键单击时,您将有一个使用代码打开的选项。

【讨论】:

    【解决方案3】:

    您可以通过 File > New window 或 ctrl+shift+n 打开一个新窗口,然后打开那里的第二个文件夹。

    或“window.openFoldersInNewWindow”设置:

    // Controls if folders should open in a new window or replace the last active window.
    // - default: folders will open in a new window unless a folder is picked from within the application (e.g. via the File menu)
    // - on: folders will open in a new window
    // - off: folders will replace the last active window
    // Note that there can still be cases where this setting is ignored (e.g. when using the -new-window or -reuse-window command line option).
    "window.openFoldersInNewWindow": "default",
    

    【讨论】:

    • 这个答案与我提出的问题无关。
    • 谢谢,这对我有用。我通过按cmd+, 并搜索open folders in new window 找到了该选项。我将它设置为on,现在它可以正常工作了。
    【解决方案4】:

    让我们变得非常简单

    1. 在 vscode 中,转到文件 --> 新窗口,如下图所示。这将打开一个空白的 vscode 窗口,我们将在其中打开新项目。

    1. 将项目文件夹拖放到 vscode 中。如下图所示

    就是这样。新的空白窗口已打开新项目。

    下面讨论另一种方式

    1. 转到您要在vscode 中打开的文件夹 URL。在文件位置,输入 URL cmd
    2. cmd 提示符将打开文件夹 URL。
    3. 在 cmd 提示符下,输入code .
    4. 您的文件夹将在新的vscode 窗口中打开。

    【讨论】:

      猜你喜欢
      • 2016-09-15
      • 1970-01-01
      • 2017-11-28
      • 1970-01-01
      • 2022-01-13
      • 2021-04-02
      • 1970-01-01
      • 2022-07-19
      相关资源
      最近更新 更多