How do I open a file that's open in one pane again in another?

Answered

I would like to have the file open in more than one pane so that I can see two different parts of the file at the same time. This is easy to do by creating a new pane, but I can't seem to figure out how to do it (if it can be done) with existing panes -- that is, to open a file in an existing pane while it's already open in another pane.

In previous versions of IntelliJ IDEA (maybe 6 or before), opening a file in more than one pane was easy - simply open the file when the active pane doesn't already have the file open. However, in the current version, when I try to open a file that's already open in another pane, IntelliJ will automatically switch to the one that's already open instead of opening it again.

I know that it is technically possible for the current version of IntelliJ to have a file open in more than one pane. This can be accomplished by selecting "split vertically" or "split horizontally"; the current pane splits and the file that was active is now open in the previous and the new pane. However, I would like to be able to open a file more than once in panes that already exist. For example, namely, I pretty much always have two panes open (split vertically). With file foo.java open in left pane (and bar.java open in the right pane), I would like to open another foo.java tab in the right pane (without creating another split or having to close any other tabs/panes). How can I do this, if it is possible? (If not, anyone know why?)

To me, the ideal solution would be to have an "Allow a file to be opened in mulitple panes" option in Editor Settings. Then, if I explicitly open a file (viz., open it via the Project Tool Window, or Go To Class (CTRL-N)), it would then open the file (again) in the active pane (or go to the open file if it's already open in the active pane). Jumping to source (via, say, Go To Declaration) would/could still jump to the already-open file in whatever pane it is open in.

Thanks for the help,
~Robert


version: 8.0.1
platform(s): Windows XP and Mac OSX
additional keywords: multiple multi pane panes window windows tab tabs once twice

Edited message for clarity. -Robert

0
23 comments

I remember using this feature years ago and I still miss it. It was
useful to have a file open in multiple panes. I think the current
(deteriorated) split pane behaviour has been around since IDEA 7.

--
Esko Luontola
www.orfjackal.net

0

There's also this related issue:
http://www.jetbrains.net/jira/browse/IDEABKL-4949

--
Esko Luontola
www.orfjackal.net

0
Avatar
Forums Migration User

1) Right click in window that you want to have in two panes
2) Select Window->slipt horizontally
Now file is in two panes

-Rob

-2

Rob,

I'd like to be able to open the file again without opening a new pane.

I always have multiple tabs open in two panes (split vertically). A file that I have open in one pane I'd like to also open in the other existing pane (without creating a new pane, nor closing other tabs).

~Robert

0

Very clearly written question. I need the same thing and have asked for a solution on stackoverflow.

http://stackoverflow.com/questions/1846565/how-to-create-two-editor-windows-for-the-same-file

2

The correct tracker issue for this problem would be http://youtrack.jetbrains.net/issue/IDEA-34593 . Please Watch/Vote.

2

While the above IDEA-34593 was ultimately fixed, there's a lingering but extremely irritating UX issue with how files are opened in a different pane ("group") then the focused one when they are already open. Please vote if you'd like to see that changed. 

0

8 years later... the situation is the same.

There is no way to open an already opened file in an existing split with the keyboard...

0

Does anyone have a solution for this? I have a multiple monitor setup and after opening a file with cmd+shft+O my cursor often jumps to a different monitor. Hunting down where the file was opened is a pretty significant distraction to my workflow.

Thanks!

Just to add a workaround. Behavior is correct if the file was previously opened with "split-window" and exists as a tab in the current pane. My workaround currently is the following: When I open a file and the cursor jumps to an undesired open pane, I open the file again with split-window and drag the newly created tab into the pane that I wanted to originally open the file in. It's annoying but happens less often as my common files get instances in each pane. Is it possible to automate this workaround?

1

Brandon, I think https://youtrack.jetbrains.com/issue/IDEA-67559 is related to this issue - you might want to vote on it.

In one of the tickets linked to it as related, https://youtrack.jetbrains.com/issue/IDEA-121003, someone (Gary Clayburg) was talking about creating a plugin. That could probably address the issue.

0
Avatar
Michael Parmeley

The option you are looking for is "Open in Opposite Group". It doesn't have a keyboard shortcut assigned to it by default. You can assign one through keymap settings. If you don't use it often enough to require a keyboard shortcut search for the action and execute it from there:

 

put your cursor in the file you want to open in the other side of the split editor->cmd-shift-a->type "open opp"->select "open in opposite group"

 

A second way to do it:

  1. Put the cursor in the editor you want the class to display in
  2. Bring up the search for class dialog (alt-o in my mac keymap, can't remember if I customized this or not)
  3. search for your class
  4. Select it then hit cmd-shift-enter, it will open in the editor your cursor is in even if it is already open in another editor pane
1

Here's how to do it:

Alt-Shift-Enter

In the 'Open File' or 'Go To Class' dialog, or Project view, press Alt-Shift-Enter (instead of just Enter) to have the selected file open in the current pane even if it's already open in another pane.

Shift-Enter will open the file in a floating window.

Older versions of IntelliJ

In older versions of IntelliJ (maybe before IntelliJ 2016, and sometime after IntelliJ 8): this shortcut was just Shift-Enter.

0

I would like to add to previous messages that having the ability to open multiple files side by side vertically makes a lot more sense as it easier to read, at least to me and other users with the same preference. Implementing such change should be a big one considering it's already supported the horizontal split. Could this be a bit prioritised please? This is a premium IDE, isn't? I'm currently using WebStorm and IntelliJ paid versions. Thanks in advance.

0

Jp Proverbio, in the current IDE version it's possible to split the Editor tab both horizontally and vertically, these are Split Down and Split Right actions in the tab's context menu, respectively. Does the Split Down provide the functionality you mean?

0

Hi, does alt+shift+enter shortcut still works on newest release ?

I remember it worked fine some time ago, but at some release it stopped.

Is my setup broken or do I need to write plugin to replicate target behaviour ? 

 

0

@Jakubb126 in 2022.1.4 this action does not work indeed which appears to be a bug. But in the 2022.2 released yesterday it works fine for me. Could you please indicate your IDE version? 

0

I just updated to 2022.2 - Build #IU-222.3345.118, but problem persists, nothing happens on Alt+Shift+Enter. Spilt right works though.

0

Jakubb126 sorry for confusion, it's a Shift+Enter that works for me to open the selected file in a new split, that is, Alt+Shift+Enter shortcut has changed for Open in Right Split action described in this comment.

For split actions that can be invoked from the Editor tab there are no default shortcuts, but you can assign them if necessary.

 

0

So, is there in the end *no way* to force opening in current split? This seems like a major disappointment, for this otherwise excellent IDE.

Maybe instead of a new action just a setting? Which, when opening, would only search the current split instead of all of them.

0

Hi Jaskij - a simple Enter on the file selected in the Project view opens it in the currently focused split.

0

Jaskij there's an option in IDE Settings > Advanced settings, Editor tabs called When navigating to a file, prefer selecting existing tab in inactive split pane. Disabling it might help in your scenario. If it does not, please describe in more details how exactly you open the file that is not opened in the split you want. Thanks!

5

Ekaterina Valeeva THANK YOU this is precisely what I was trying to do (same thing as everyone else on this thread, I gather)

 

 

0

Ekaterina Valeeva THANK YOU this is precisely what I was trying to do (same thing as everyone else on this thread, I gather)

0

Please sign in to leave a comment.