phhu
phhu

Reputation: 1952

Open files in left or right-most editor group in VS code

Is there a means to always open files chosen in VS Code's file explorer in a particular code editor group, say the left or right-most group?

I can use "Open to the side" (Ctrl-Enter) to open a file in a new group, to the right. Otherwise a file opens (in preview or otherwise) in the currently active group. This can be annoying, because often I'm working on a file in the active group, and want to refer to another file in a side group which I already have open (with another file in it), rather than a new side group. I have to activate the side group first, and then open the file I want to see: but I usually forget which group is active, and open the file I want to look at in place of the one I was editing...

I can use Ctrl-1, Ctrl-2 etc to switch to a group before opening a file: but I'd rather be able to use the file explorer as a GUI to explore files, without having to think: if I could "pin" the file explorer to a given editor group, it would be simpler.

Upvotes: 8

Views: 3778

Answers (3)

thealch3mist
thealch3mist

Reputation: 21

Locking the group is a great suggestion but you need to remember to do that for every project you open on VSCode. An alternative quick shortcut I use is

Ctrl+Alt+Left/Right

to move the opened file between groups. You can change the binding from Preferences: Open Keyboard Shortcuts as shown here: settings to edit

Upvotes: 1

Tune
Tune

Reputation: 161

What you can do is lock the group where your reference file is - for example on the right side - by clicking on the three dots within that group and then clicking Lock group, as shown:

Image for lock group setting

This will make sure that no new files are opened in that group, but instead will be opened in your other group, on the left side.

Upvotes: 13

Grekkq
Grekkq

Reputation: 766

Currently it is not possible. But i think there are two workarounds you could try to use:

  • Always close editor/editor group that you don't need so you would have only one editor open at the time of opening to side. To close current editor by default it is CTRL+F4 and to close whole editor group there is no default shortcut so you would have to add it yourself in Keyboard Shortcuts tab.

  • Limit the number of opened editors at one time to just 2, so opening to the side will replace older editor (not the one that was active last time). To do that you have to modify this two following settings:

    "workbench.editor.limit.value": 2,
    "workbench.editor.limit.enabled": true,
    

    settings to edit

Or you can just drag and drop with your mouse the file to the editor you want ;P

EDIT: It would also be possible to create custom shortcut for that (checks if there are multiple editor groups multipleEditorGroups and if so closes them and then just call open to side), here is example how to create one

Upvotes: 2

Related Questions