首页 > 解决方案 > VSCode shorcut to tab between files on secondary editor group

问题描述

I'm currently using VSCode to edit latex documents. The setup I have is the latex document in one editor group to the left, and then the preview of the document (pdf) in another group to the right. Additionally, I keep some other files open in the right work group as well.

Is there a way to make a shortcut, which tabs through the files in right work group, while the focus remains on the left one?

标签: visual-studio-codekeyboard-shortcutskeymappingkeymaps

解决方案


我认为没有任何内置方法可以做到这一点。您可以很容易地使用宏来完成它。使用像multi-command这样的宏扩展将其放入您的设置中:

"multiCommand.commands": [

 {
  "command": "multiCommand.NextEditorOtherGroup",
  "sequence": [
    "workbench.action.focusNextGroup",
    "workbench.action.nextEditorInGroup",
    "workbench.action.focusNextGroup"
    //  "workbench.action.focusPreviousGroup" if you more than two editor groups for example
  ]
 },
{
  "command": "multiCommand.PreviousEditorOtherGroup",
  "sequence": [
    "workbench.action.focusNextGroup",
    "workbench.action.previousEditorInGroup",
    "workbench.action.focusNextGroup"
  ]
 }
]

宏只关注另一个编辑器组(它假设你只有两个,如果你有更多宏可以修改以关注right/last/most recently used编辑器组。在关注另一个编辑器组之后,它移动到另一个编辑器中的下一个/上一个编辑器组,然后将焦点返回到另一个组(因为您只有两个编辑器组focusNextGroup在这里工作得很好,如果您有更多并且想要返回到以前集中的组使用workbench.action.focusPreviousGroup)。

然后是您想用来触发这些宏的任何键绑定(在 keybindings.json 中):

{
  "key": "alt+q",              // trigger the macro with any keybinding you wish
  "command": "extension.multiCommand.execute",
  "args": { "command": "multiCommand.NextEditorOtherGroup" },
  "when": "editorTextFocus"
},
{
  "key": "shift+alt+q",        // any keybinding
  "command": "extension.multiCommand.execute",
  "args": { "command": "multiCommand.PreviousEditorOtherGroup" },
  "when": "editorTextFocus"
},

推荐阅读