I’m working with Visual Studio Code and trying to create a custom keybinding that behaves differently depending on whether the cursor is in the left or right pane of a split editor.
My question is:
Are there any context keys in VSCode that can detect whether the active editor is in the left or right pane of a split view?
If not, is there an alternative way to achieve this distinction in keybindings or settings?
I’ve searched the VSCode documentation and experimented with various context keys, but so far haven’t found a solution. Any insights or workarounds would be greatly appreciated.
Environment:
Visual Studio Code Version: Version: 1.89.1 (User setup)
OS: Windows_NT x64
I’ve enabled Developer Mode and used the "Developer: Inspect Context Keys" command to search for relevant context keys, but haven’t found anything that distinguishes between left and right split panes.
2
Answers
Most probably you can get pretty far using
groupEditorsCount
andactiveEditorGroupIndex
:Try the following keybindings:
The above will open the SideBar if it is closed. It isn’t clear to me if that is your desired behaviour or if you want to ignore the SideBar if it isn’t open. Let me know and I can change the above.