VSCode: 选择文件后将焦点保持在文件夹面板中
VSCode: keep focus in folders panel after selecting a file
我希望能够通过键盘高效地在 VSCode 工作区中导航文件:在找到合适的文件之前,通过查看数十个文件来探索存储库。
我可以通过单击在“文件夹”视图中突出显示某些文件,然后使用箭头导航(到目前为止还不错),但是当我单击 Enter
时,文件会打开 并且编辑器获得焦点 - 这阻止我进一步导航树。
是否可以配置 VSCode 让编辑器在我从侧边栏打开后不聚焦?
到目前为止我发现的最好的是可以创建一个键绑定来将焦点带回资源管理器:ctrl-shift-p
> Preferences: Open Keyboard Shortcuts
> 寻找 workbench.explorer.fileView.focus
(通过默认没有分配键绑定)。
[编辑}:从 v1.38 开始 添加了一个新命令,允许您打开资源管理器文件并在资源管理器中保持焦点:
Open file and preserve focus
Now it is possible to open the file in preview from the explorer while
preserving the focus in the explorer. The new command is
filesExplorer.openFilePreserveFocus
and by default it can be triggered
via the space
key.
来自 open file and preserve focus
[原始答案 - 现在见上面的编辑]
您可以使用宏扩展一步完成此操作,该宏扩展使您可以使用 enter
键 运行 两个命令。这里我使用的是 multi-command extension,它有一个 interval
延迟选项。命令之间的 150 毫秒延迟似乎有必要允许在将焦点切换回文件资源管理器之前打开文件。
"multiCommand.commands": [
{
"command": "multiCommand.openFileKeepFocusInExplorer",
"interval": 150,
"sequence": [
"list.select",
"workbench.explorer.fileView.focus",
]
}
]
然后为 multi-command:
分配一个键绑定(在 keybindings.json 中)
{
"key": "enter",
"command": "multiCommand.openFileKeepFocusInExplorer",
"when": "sideBarFocus && activeViewlet == 'workbench.view.explorer'"
},
在下面的演示中,我只使用 arrow
和 enter
键在文件之间移动,打开它们并在文件资源管理器中保持焦点:
我希望能够通过键盘高效地在 VSCode 工作区中导航文件:在找到合适的文件之前,通过查看数十个文件来探索存储库。
我可以通过单击在“文件夹”视图中突出显示某些文件,然后使用箭头导航(到目前为止还不错),但是当我单击 Enter
时,文件会打开 并且编辑器获得焦点 - 这阻止我进一步导航树。
是否可以配置 VSCode 让编辑器在我从侧边栏打开后不聚焦?
到目前为止我发现的最好的是可以创建一个键绑定来将焦点带回资源管理器:ctrl-shift-p
> Preferences: Open Keyboard Shortcuts
> 寻找 workbench.explorer.fileView.focus
(通过默认没有分配键绑定)。
[编辑}:从 v1.38 开始 添加了一个新命令,允许您打开资源管理器文件并在资源管理器中保持焦点:
Open file and preserve focus
Now it is possible to open the file in preview from the explorer while preserving the focus in the explorer. The new command is
filesExplorer.openFilePreserveFocus
and by default it can be triggered via thespace
key.
来自 open file and preserve focus
[原始答案 - 现在见上面的编辑]
您可以使用宏扩展一步完成此操作,该宏扩展使您可以使用 enter
键 运行 两个命令。这里我使用的是 multi-command extension,它有一个 interval
延迟选项。命令之间的 150 毫秒延迟似乎有必要允许在将焦点切换回文件资源管理器之前打开文件。
"multiCommand.commands": [
{
"command": "multiCommand.openFileKeepFocusInExplorer",
"interval": 150,
"sequence": [
"list.select",
"workbench.explorer.fileView.focus",
]
}
]
然后为 multi-command:
分配一个键绑定(在 keybindings.json 中){
"key": "enter",
"command": "multiCommand.openFileKeepFocusInExplorer",
"when": "sideBarFocus && activeViewlet == 'workbench.view.explorer'"
},
在下面的演示中,我只使用 arrow
和 enter
键在文件之间移动,打开它们并在文件资源管理器中保持焦点: