skip to Main Content

VSCode provide a command: workbench.action.focusFirstEditorGroup to focus buffer of first editor group.

But what I need is:

After I press `<option+l>`
if current group is the first one
    focus Explorer
else
    move to previes editor group

So I need to check whether current group is the first group.

Is there a way to make it? Thanks!

2

Answers


  1. There is a context key you can use: activeEditorGroupIndex.

    If the active editor is in the first group then activeEditorGroupIndex will = 1, and so on.
    So try these keybindings:

    {
      "key": "alt+l",         // whatever you want, just make it the same as below
      "command": "workbench.files.action.focusFilesExplorer",
      "when": "activeEditorGroupIndex === 1"
    },
    {
      "key": "alt+l",
      "command": "workbench.action.focusPreviousGroup",
      "when": "activeEditorGroupIndex !== 1"
    }
    
    Login or Signup to reply.
  2. You can cycle between the VSCode panes using workbench.action.navigateRight or workbench.action.navigateLeft

    [
        {
            "key": "alt+l",
            "command": "workbench.action.navigateRight"
        },
        {
            "key": "alt+h",
            "command": "workbench.action.navigateLeft"
        },
    ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search