At some point you’ll want to view the same class or file side by side. You may want to follow related code in different parts of the class or need some code constantly available as reference to change some other part of the class.
Eclipse allows you to split an editor and move it to anywhere in the editor area in the same window, including next to the original editor. Changes made in the one editor are reflected in the other. The feature isn’t very obviously named, but it is easy to use.
How to view the same editor side by side
To get the same editor side by side, select Window > New Editor and then drag the new editor next to the original one.
As an example, watch the video below to see how to split the editor and move it next to the original.
- It may help to maximise the original editor first (Ctrl+M) to gain some screen space. You can then move the 2nd editor next to, above or below the original editor.
- It’s not that clear that you can drag the editor next to the other one, so watch the video carefully for the outline that indicates when you can drop the other editor. It’s not that easy to get it right the first time, but play around with the different positions to see what works for you.
- Changes made in one editor will reflect in the other one, but scrolling is (fortunately) independent.
Some keyboard shortcuts to help with this feature
Once you’ve got the editors side by side you may want to switch between them without having to use the mouse. To do this, press Ctrl+F6 once. This will switch between the last two active editors. In general, Ctrl+F6 cycles through all open editors, in order of the most recently active editor.
Tip: I’d also recommend mapping Ctrl+F6 to Ctrl+Tab by adding a mapping for the key Next Editor under Window > Preferences > General > Keys. It works a lot better than Ctrl+F6 since you can press the key without lifting your hands.
If you use often split editors, you may want to use the keyboard to split editors without using the mouse to activate the menu option. Here are two ways to do this:
- Go to Window > Preferences > General > Keys. Search for the key New Editor and enter any keystroke you’d like to use (eg. Alt+Shift+B, E). Recommended
- Alternatively, just press Alt+W, E. This uses the menu mnemonics to activate the New Editor menu option without having to remap any keys. This may not work if you have a plugin that registered another command under the Window menu with the mnemonic E or if mnemonics are affected by your OS settings. This should work most of the time, but for these reasons, the first method is recommended.
- The fastest ways to open editors in Eclipse using the keyboard
- Switch and close editors faster with the keyboard using Eclipse’s Quick Switch Editor
- Quick ways to navigate Eclipse editors using the keyboard
- More tips on how to work faster with editors.