VS Code键绑定配置咨询:修改资源管理器'o'键及添加活动文件定位绑定
解决方案
1. 实现活动文件在资源管理器中定位并返回编辑器焦点
打开VS Code的键盘快捷方式JSON配置(通过命令面板Ctrl+Shift+P,输入Preferences: Open Keyboard Shortcuts (JSON)),添加以下配置:
{ "key": "你自定义的快捷键(比如ctrl+shift+r)", "command": "runCommands", "args": { "commands": [ "revealInExplorer", "workbench.action.focusActiveEditorGroup" ] } }
revealInExplorer:将当前活动文件在资源管理器中定位workbench.action.focusActiveEditorGroup:将焦点切回编辑器
2. 修改资源管理器中'o'键的行为
同样在键盘快捷方式JSON配置中,添加以下配置覆盖默认的'o'键绑定:
{ "key": "o", "command": "runCommands", "args": { "commands": [ "explorer.open", "workbench.action.focusActiveEditorGroup" ] }, "when": "explorerViewletVisible && filesExplorerFocus && !inputFocus && resourceType == 'file'" }, { "key": "o", "command": "explorer.toggleExpand", "when": "explorerViewletVisible && filesExplorerFocus && !inputFocus && resourceType == 'folder'" }
- 针对文件:执行
explorer.open打开文件后,立即将焦点移至编辑器 - 针对目录:保留原有的
explorer.toggleExpand(展开/折叠)行为 when条件确保仅在资源管理器聚焦、无输入框焦点时生效,且区分文件/目录类型
内容的提问来源于stack exchange,提问作者Ty Kroll
相关产品推荐
相关产品推荐

