【问题标题】:Instantly open files when navigating the file explorer with arrow keys in VScode在 VScode 中使用箭头键导航文件资源管理器时立即打开文件
【发布时间】:2017-10-20 16:14:53
【问题描述】:

目前,我使用箭头键在 VScode 中导航文件树,并且必须按 Cmd + Down 才能在编辑器中显示文件.

有什么方法可以在 VScode 中浏览文件资源管理器并在焦点/突出显示时立即打开文件而无需快捷方式? (类似于它在崇高文本中的工作方式)

【问题讨论】:

  • 如果我正在浏览大型新代码库,我会非常感激。
  • 还没弄明白,但是有一个“打开文件...”命令带有一个未分配的键绑定。当我尝试将它(workbench.action.files.openFile)添加到命令是 keybindings.json 时,它说该命令不存在...code.visualstudio.com/docs/getstarted/…
  • 也许认为您正在寻找的行为是preview,而不是open 每个文件?

标签: visual-studio-code keyboard-shortcuts


【解决方案1】:

正如在这个 github 问题中所写:(Open File Preview when using Keyboard navigation in Explorer for better accessibility. #55816),从(至少)2019 年 8 月 28 日起,可以

预览文件,通过在资源管理器中使用 Up/Down 选择它们并按 空格

使用 shift+cmd+E 可以轻松切换到文件浏览器。 这不像箭头键那么简单,但仍然比问题中描述的更方便。

【讨论】:

    【解决方案2】:

    目标:通过Explorer VS Code 视图查看项目中的大量文件。

    这是一个有点长(但易于理解)的过程 - 但是一旦完成,您以后会节省很多时间。


    1 .安装multi-command扩展

    https://marketplace.visualstudio.com/items?itemName=ryuta46.multi-command

    2 。菜单 > 文件 > 首选项 > 设置
    或者,Ctrl + ,

    3 .点击右上角的“打开设置(JSON)”按钮

    4 。粘贴在下面:

      "multiCommand.commands": [
        {
          "command": "multiCommand.navigateExplorerDownAndPreviewFile",
          "sequence": ["list.focusDown", "filesExplorer.openFilePreserveFocus"]
        },
        {
          "command": "multiCommand.navigateExplorerUpAndPreviewFile",
          "sequence": ["list.focusUp", "filesExplorer.openFilePreserveFocus"]
        }
      ],
    

    5 .菜单 > 文件 > 首选项 > 键盘快捷键
    或者,Ctrl K + Ctrl S

    6 .点击右上角的Open Keyboard Shortcuts JSON按钮

    7 .将以下两个条目粘贴到您的数组中

    [
        {
            "key": "down",
            "command": "multiCommand.navigateExplorerDownAndPreviewFile",
            "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && listFocus && !inputFocus"
        },
        {
            "key": "up",
            "command": "multiCommand.navigateExplorerUpAndPreviewFile",
            "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && listFocus && !inputFocus"
        }
    ]
    

    8 .菜单 > 视图 > 资源管理器
    或者,Ctrl Shift E

    9 .在资源管理器中选择左侧的任何文件

    您可以打开一个包含多个文件的文件夹(例如,.js 文件)

    10 .尝试使用以下键盘快捷键打开下一个/上一个文件

    • up arrow 转到上一个文件,并在中间窗格中查看它
    • down arrow 转到下一个文件,并在中间窗格中查看它

    现在,您已设置为仅使用 updown 箭头键,通过 vs 代码中的资源管理器预览文件。

    【讨论】:

    • 太棒了,非常感谢?
    猜你喜欢
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多