当我打开一个文件时,我希望有一个快捷方式可以在
EXPLORER
内导航到该文件,以便我可以看到它所在的位置。
我该怎么做?
在命令面板(F1)中,有一个
Files: Reveal Active File in Side Bar
命令。您可以通过键盘快捷键编辑器为其分配快捷键:
或者,您可以尝试 Reveal 扩展,将此按钮添加到编辑器中:
使用此快捷方式作为“手动显示”时,禁用自动显示可能是有意义的:
// Set this in your settings.json file
"explorer.autoReveal": false
只需按 Cmd + Shift + E,资源管理器就会显示您正在查看的文件。
在 Linux Ubuntu 20.04 上的 Visual Studio Code 1.78.0 中进行了测试。
无需扩展。
几个额外的简单方法:
[已经在这个答案中提到,我第一次学到它]
右键单击窗口顶部感兴趣的文件选项卡-->“在资源管理器视图中显示”,如下所示:仅适用,如果您不为"explorer.autoReveal"
设置值(因为其默认值为
true
),或(如果您已在内明确将其设置为
true
) settings.json
文件,如下所示:
// Controls whether the Explorer should automatically reveal and select
// files when opening them.
// - true: Files will be revealed and selected.
// - false: Files will not be revealed and selected.
// - focusNoScroll: Files will not be scrolled into view, but will still be
// focused.
// GS note: default is `true`
"explorer.autoReveal": true,
"explorer.autoReveal"
settings.json 设置。