You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 00:12:40