You’ll often end up with a lot of open editors in Eclipse and consequently needing to navigate between them. You can use the mouse for this, but that often disturbs your flow when your typing, slowing you down.
That’s why there are a number of ways to navigate between editors in Eclipse using only the keyboard. Combined with the ability to quickly navigate views using the keyboard, it’s an easy way to work faster and almost get rid of the mouse (reducing company spending… well, slightly).
Cycle through open editors
This is probably the fastest way to navigate between editors in most cases. When you press Ctrl+F6 (Next Editor), a popup appears with a list of all open editors. The list is sorted in order of most recently used, so if you press Ctrl+F6 and release it immediately, Eclipse will take you to the last active editor. Press Ctrl+Shift+F6 to reverse the direction.
This is a great way of jumping between 2 editors, eg. to read something in the one while typing in the other. Here’s an example showing what happens when you press Ctrl+F6 while on Template.java.
I strongly recommend mapping the Next Editor command to Ctrl+Tab in addition to (or instead of) Ctrl+F6. Just make a binding for the command Next Editor under Window > Preferences > General > Keys – see how to manage your keyboard shortcuts for details on how to do this. But why remap the key? Well, not only is it a lot easier and faster to press (you can use one hand to do this), it’s also standard for most Windows applications so you may already be familiar with it. It makes switching editors 5 times faster (yes, statistically proven).
Another way of using cycling is to press Ctrl+F6 and then press F6 repeatedly while holding down Ctrl. Eclipse will highlight the next editor in the list until you release Ctrl, after which it will activate the highlighted editor. This is a good way to navigate a short list of editors (eg. 5-10 open editors) but can get a bit cumbersome when there are more editors.
Quick Switch Editor
Another fast way of navigating editors is via the Quick Switch Editor functionality. I’ve posted another tip dedicated entirely to this feature, so won’t discuss it in detail here but just give a brief rundown of how it works. Basically, it’s great when you have a large number of editors open.
By pressing Ctrl+E, you can get a list of all open editors. This list is searchable and even supports wildcards, which is why it’s great for cases where you have a large number of editors open. The Quick Switch Editor is also flexible in that it supports closing editors directly without activating them. Here’s an example of what you’ll see:
Move sequentially from one editor to the next
You can also move between editors in the order of their tabs in the editor area. To move to the next editor just press Ctrl+Page Down, while Ctrl+Page Up takes you to the previous editor.
In the example below, when you press Ctrl+Page Down, Eclipse will activate the editor Engine.java, assuming that we’re currently positioned on TestSomeUtils.java. Repeating this will take you to ClientDataSource.java.
Moving between editors sequentially is sometimes useful, but the big drawback of it is that it doesn’t consider which editors you’ve been working on recently (in my experience, the more likely case) so can be slow in those scenarios.
Bonus Tip: If you’re wondering how to move between different pages of a multipage editor (eg. plugin.xml below), then just press Alt+F7 to move to the next page and Alt+Shift+F7 for the previous page. Multipage editors used to “break” Ctrl+Page Down navigation in previous versions of Eclipse because they’d hijack the key preventing you from moving to the next editor. This has changed in Eclipse 3.5.
Which one should I use when?
Here are some recommendations on when to use what to work most efficiently:
- If you want to quickly move between the editors you’ve used recently, use editor cycling . This is such a common requirement, that this is probably the editor navigation I use the most. Remember to create an additional binding for it to Ctrl+Tab – it works a lot faster.
- If you’ve got a large list of open editor (eg. 10+) then use the Quick Switch Editor. Editor cycling is a decent choice up until about 10 editors.
- If you just quickly want to browse the editors one by one to scan through them (eg. you have a couple of XML files you want to scan briefly), then use the sequential navigation.
In summary, focus on learning editor cycling, then using the Quick Switch Editor. After that, pick from some of the others depending on how you work.
Quick mentions
Here are a couple of other ways to navigate editors, but, although they do come in handy sometimes, they may not be as efficient as the ones above.
- While editing and navigating through editors, you’ll often want to go back to the last place you were editing. Just press Ctrl+Q and Eclipse will take you directly to the exact location where you were last editing. This way you don’t need to trace your steps to get back to your last edits. Even comes in handy when you have to scroll through the same file then go back to the last edit.
- Use Eclipse’s History functionality to move back to previous editors, similar to using a browser history. Press Alt+Left to go back to the previous editor and Alt+Right to go forward. This is useful when switching back and forth between 2 different editors or when you want to an editor that you’ve closed, as the history also reopens closed editors.
- An overlooked-but-useful Eclipse feature is the most recently used list under the File menu. Just press Alt+F, 1 (or any other number that’s indicated in the menu) to go to the most recently opened editor. This is useful when you’ve accidentally closed an editor you still want to use.
Related Tips
- 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
- Split and view the same editor side by side in Eclipse
- The fastest ways to navigate views in Eclipse using the keyboard
- How to manage keyboard shortcuts in Eclipse and why you should
- Here are more ways to navigate faster and use editors more efficiently in Eclipse.
Ctrl + Q is also nice: Last Edit Location (place of last modification). When I edit one file but navigate to others to check the details, or scroll within the editor to display some referenced method or field, Ctrl + Q quickly takes me back to the part that I’m working on.
That’s definitely a good one to add to the list, Kofa. It’s a very handy shortcut. So handy, in fact, that I’ve actually updated the post and mentioned it in the Quick Mentions.
Thanks for mentioning that.
I would also recommend to re-map Previous Editor (CTRL-SHIFT-F6) hotkey to CTRL-SHIFT-TAB, that goes nicely to CTRL-TAB that you suggested.
Thanks for that Aleksey, I think it would help a lot of people.
The funny thing is that I’ve actually mapped Ctrl+Shift+Tab to Next View instead of Next Editor. The reasons are that (a) I wanted something to replace Ctrl+F7 (Next View) that’s closeby and quick to press and (b) I don’t use Previous Editor as much as I do Next Editor. So I decided on Ctrl+Shift+Tab.
But your suggestion makes sense as they do complement each other and many would want to use Previous Editor.
If you’re looking to optimize your keyboard usage in Eclipse, then using the Emacs+ plugin can help. You might think this is only useful for Emacs users, but I would disagree (although I am an Emacs user). I use it a little differently than the “typical” Emacs+ user (according to the author). I use the plugin, but I don’t use the Emacs-similar bindings. I simply bind the keys that are convenient for me. Besides providing lots of new useful functions, Emacs+ also provides a macro facility. With this, I was able to bind a key to a function which advances to the next occurrence in the search view, all within the editor view.
In addition, if you’re looking at optimizing your keyboard usage in general, I couldn’t live without the Cap2Ctrl tool from the SysInternals web site (for Windows, of course). The Ctrl key should be very easy to use, and its typical location at the bottom left of the keyboard isn’t friendly to long-term usage. Cap2Ctrl lets me make the useless CapsLock key be another Ctrl key.
Emacs+ does look good and I’m sure Emacs users (old and current) will appreciate this. From what I saw it does provide a number of useful features and some that Eclipse should support by default, eg. macros, a feature I was looking for without success (Eclipse Monkey looks good but isn’t active anymore and the community’s nonexistent). In the end I went to back to trusty AutoHotkey for my macros requirements.
I’ve also used AutoHotkey to turn my Caps Lock into a special modifier key, eg. CapsLock+J = Left, +K = Down, +L = Right, +I = Up. This saves me from not having to move my hand to the arrow keys to move my cursor. I’ve done similar things for Backspace, Enter, Save, etc – most common commands I use. So although Caps2Ctrl sounds nice, it’s out for me.
Thanks for the suggestions – I’ll definitely give Emacs+ a go for its extra functions.
Can I turn this into a button on the toolbar?
Like having a button on the toolbar that opens “Switch to Editor..” window ? (Ctrl+Shift+E)
I haven’t seen a way to add any command to the toolbar without writing your own plugin. To access switch to editor with the mouse, the closest I can think of is if you click Window > Navigation > Switch to Editor… but that’s a bit clunky.
Are you perhaps looking for something like EditorList Plug-in which is a view that lists all the open editors? It’s very old (last updated in 2005) and I don’t think it works against Eclipse 4.x anymore but you might find something similar out there.
I know of that plugin, but it would be nice, if I was able to open “Switch to Editor..” window from the toolbar. I would like that better than the keyboard shortcut.
Thanks for your advice.