319

How do you split a window/view in Eclipse IDE? I want to edit code while viewing the different code in the same file.

If there is a trick to open the same file twice, this might do, but I would rather just split the one current view instead of having two of the same which might get confusing.

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
Xonatron
  • 15,622
  • 30
  • 70
  • 84
  • Possible duplicate of [Eclipse - Same .Java file in split view?](http://stackoverflow.com/questions/2198822/eclipse-same-java-file-in-split-view) – blahdiblah Sep 25 '13 at 00:55
  • That earlier question could be closed as the duplicate. This question has better, more contemporary answers. – Andy Thomas Jul 01 '15 at 15:58
  • 22
    If split happened by mistake, to unsplit press "ctrl"+"shift"+"-". This feature annoys me a lot. – Rauli Rajande Feb 16 '16 at 11:18
  • window>editor>Toggle split editor will get rid of the unexpected split, @Rauli shortcut didn't work for me. – Cedric Feb 26 '18 at 21:17
  • On Mac OS, the corresponding key combination to unsplit is ⌘ ⇧ - ("cmd"+"shift"+"-"). But this is only for horizontal splits. See my answer below for both horizontal split and vertical split. – auspicious99 Jan 18 '20 at 09:00

11 Answers11

365

This is possible with the menu items Window>Editor>Toggle Split Editor.

Current shortcut for splitting is:

Azerty keyboard:

  • Ctrl + _ for split horizontally, and
  • Ctrl + { for split vertically.

Qwerty US keyboard:

  • Ctrl + Shift + - (accessing _) for split horizontally, and
  • Ctrl + Shift + [ (accessing {) for split vertically.

MacOS - Qwerty US keyboard:

  • + Shift + - (accessing _) for split horizontally, and
  • + Shift + [ (accessing {) for split vertically.

On any other keyboard if a required key is unavailable (like { on a german Qwertz keyboard), the following generic approach may work:

  • Alt + ASCII code + Ctrl then release Alt

Example: ASCII for '{' = 123, so press 'Alt', '1', '2', '3', 'Ctrl' and release 'Alt', effectively typing '{' while 'Ctrl' is pressed, to split vertically.

Example of vertical split:

https://bugs.eclipse.org/bugs/attachment.cgi?id=238285

PS:

  • The menu items Window>Editor>Toggle Split Editor were added with Eclipse Luna 4.4 M4, as mentioned by Lars Vogel in "Split editor implemented in Eclipse M4 Luna"
  • The split editor is one of the oldest and most upvoted Eclipse bug! Bug 8009
  • The split editor functionality has been developed in Bug 378298, and will be available as of Eclipse Luna M4. The Note & Newsworthy of Eclipse Luna M4 will contain the announcement.
RafiAlhamd
  • 341
  • 2
  • 13
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have to give this as the new accepted answer then. Let me know if anyone has any issues with it, as I cannot test this myself. Thank you for the update! – Xonatron Dec 13 '13 at 16:48
  • Anyone know if this works on a Mac? I've had no success. And surely there's something about this feature in the menus? – galdre May 13 '14 at 13:40
  • 1
    @TimothyDean did you getthe very latest 4.4Mx on your Mac? – VonC May 13 '14 at 13:42
  • 1
    @TimothyDean note: those shortcuts might have changed since Dec. 2013: see comment 44 https://bugs.eclipse.org/bugs/show_bug.cgi?id=378298#c44. – VonC May 13 '14 at 14:12
  • I read through those already. Nothing worked. On the other hand, I may have been a little too quick to ask -- I'm using the Spring Tool Suite, not vanilla Eclipse -- that might change some things too. – galdre May 15 '14 at 23:49
  • When using RDP I am able to split vertically with Ctrl+{ but eclipse does not recognize Ctrl+_ . However, if I rebind the action to Ctrl+Shift+- it works. – Revoman Sep 03 '14 at 18:35
  • @VonC Eclipse Java EE IDE for Web Developers. Version: Luna Release (4.4.0) Build id: 20140612-0600 – Revoman Sep 04 '14 at 18:36
  • Be sure to press Ctrl-Shift-'-', not Ctrl-'-'. That's what Ctrl-_ requires. –  Nov 26 '14 at 13:49
  • @Arkadiy True: I have edited the answer to differentiate the keyboards. – VonC Nov 26 '14 at 14:07
  • +1 for the Azerty & Qwerty keyboard solution. It is surprising to see that official documentation lacks such an important information. – KrishPrabakar Jan 20 '15 at 05:33
  • 3
    Using Luna 4.4 JEE version with an Azerty keyboard, `Ctrl+_` works but not `Ctrl+{` – JacquesLeRoux Feb 22 '15 at 17:14
  • @JacquesLeRoux that seems consistent with where the '`{`' is placed in an azerty keyboard. – VonC Feb 22 '15 at 18:45
  • It worked for me ... by accident. I had to come here to learn how to turn if it off (and avoid making the same typing mistake in the future) – demongolem Apr 20 '17 at 16:09
  • Thanks, this is a life saver and I end up googling it any time I split my window by mistake. I think that for an IDE, using `{` as part of a keyboard shortcut is not the brightest idea one can have. – gd1 Jul 20 '17 at 15:36
99

You can open a new editor from the Window menu.

This will give you your current editor once again.

DerMike
  • 15,594
  • 13
  • 50
  • 63
  • 3
    Thank you. So open a new editor and adjust the two as I please. Is this the only way? A split function would be best if it existed. – Xonatron Feb 27 '12 at 20:23
  • 60
    You can click and hold on the editors title and drag it to the lower side of your screen. It will snap there and Eclipse will present you something very similar to a split screen. (see http://www.youtube.com/watch?v=wHdvDwjQELI) – DerMike Feb 27 '12 at 20:26
  • 1
    This doesn't seem to work in Eclipse Kepler any more. The option still lives on the Window menu, but seems to do nothing. Any thoughts? – djbp Oct 29 '13 at 09:32
  • 4
    I've just figured it out - it no longer automatically splits the screen and instead required that you click the tab and drag to another part of the window. – djbp Oct 29 '13 at 09:58
  • 2
    Be very careful in Kepler: each instance of the file window is *independant*. If you modify the content in one, the other is *not* modified. It really is editing the same file in two different editors with all the issues of concurrent editing. It would still work somewhat if you use one instance as a read-only reference. – leokhorn Mar 06 '14 at 09:57
  • so i opened a new splitted window. But now I want to close that window. but how to do it. there is only minimize and maximize buttons. 9No close button). eventhough the file is closed that window exists!!! – Samitha Chathuranga Sep 24 '14 at 04:24
37

If you right click on one of the tabs, one of the options should be New Editor (for me, it's at the bottom). Select that, and then drag the new tab onto the bottom scroll bar of the code editor, which will split the editor panel in two.

Michael Morgan
  • 816
  • 5
  • 6
  • 4
    The key is to drag the new opened editor to reach the bottom border of the old editor, then a black arrow and a black line at the middle of the old editor will appear to indicate that you split the editor successfully. – zhihong Sep 26 '13 at 13:35
35

Just click and drag editor title to left, right, top or bottom

asok Buzz
  • 1,876
  • 3
  • 24
  • 50
  • 2
    Ah ha! Just drag it back. However...this is weird. Sometimes when I drag a *single* tab down it moves all tabs *except* one down, instead of just the one I drug down. Other times it moves just the one I drug down. I can't figure that one out. Maybe it is an order of operations/order of tabs opened thing? Or maybe it is a bug? – Gabriel Staples Apr 04 '18 at 00:33
  • 1
    @GabrielStaples just drag that split window in between other screens tab where you want to position – asok Buzz Apr 05 '18 at 00:38
23

I tried the above solutions in Eclipse Luna 4.4.1 but couldn't open two (or multiple editor windows for different files side by side).

Simplest Solution:

  1. Open all files you want in a single window.
  2. Drag the tab of each of the files to right or to the left, eclipse will automatically display a split screen display and will split the editor into two windows once you leave the mouse button.
  3. repeat for each file/tab.

Happy Coding!

Ahmed Osman
  • 341
  • 2
  • 3
  • 1
    This is the best answer. The others either open a duplicate tab only or have way too many steps. – Matt West Aug 03 '17 at 22:47
  • This is the only legit answer that tells how to view 2 differeent files side by side. The most voted answer shows how to split the same file (which doesn't answer the question) – Thyag Jan 19 '20 at 10:27
20

Side by side editors in single Eclipse window.

  1. You have an Eclipse window showing a single editor.
  2. Window -> new editor. You now have two editor tabs.
  3. Click and drag one tab towards the right and a green outline of a vertical screen appears (drag tag towards the bottom and an outline of a horizontal screen outline appears). You can let go as soon as the outline appears.
  4. Open file of choice in 2nd editor (recent files show up at bottom of file menu).

ADT/Eclipse:Build: v22.3.0-887826

Mike P
  • 742
  • 11
  • 26
  • 1
    This is a very nice feature and good to know, but technically the question was about splitting the view for observing two parts within the same file. Your answer applies to viewing separate files side-by-side. – akauppi Mar 20 '14 at 13:20
  • The way Stephen described it, you'll get two editors on the same file. – Mike P Sep 26 '14 at 15:33
  • Although I like the Eclipse Luna answer in theory, this is the answer I chose because I am on an older version. Despite akauppi's comment of 3/20/14, I had no problem following the instructions and having the same file on the left and right. – Clint Brown Apr 08 '18 at 18:15
6

You might want to check an eclipse plugin called HandySplit

It allows to split an editor into two and move tabs from one editors stack to another with keyboard shortcuts only.

That works on Eclipse Juno or higher. For the previous Eclipse versions check this out

akikhtenko
  • 114
  • 1
  • 1
5

Simply go to Window > New Window

This will open up a new window of the same Workspace in eclipse.

You can open up separate files in each Window.

Allan
  • 96
  • 1
  • 3
4

Below are the steps to split editor horizontally or vertically go to:

Window -> Editor -> Toggle Split Editor (Horizontal) 

to split editor horizontally or

Window -> Editor -> Toggle Split Editor (vertical) 

to split editor vertically.

It will open two editors side by side or will pileup tow.

Mathieu Gemard
  • 514
  • 7
  • 11
mnc
  • 41
  • 1
1

If you want to see two different files in same eclipse you can,

Right-click a tab -> Detach

Now you can see both files at the same time without opening new eclipse and you can drag and reatach to tabs again.

Rohith Murali
  • 5,551
  • 2
  • 25
  • 26
1

On Mac OS, the key combination to toggle spit/unsplit for horizontal split is ⌘ ⇧ - ("cmd"+"shift"+"-"), whereas for vertical split, it is ⌘ ⇧ [ ("cmd"+"shift"+"[")

auspicious99
  • 3,902
  • 1
  • 44
  • 58