Switch and close editors faster with the keyboard using Eclipse’s Quick Switch Editor

I spend a huge amount of my programming time in editors, editing, switching between them and closing them. This means that managing editors has to be as efficient as possible, which means that, for one thing, I shouldn’t be swapping between the mouse and keyboard all the time to work with editors.

Luckily, there is a way to manage editors using the keyboard (and it doesn’t involve the laborious Ctrl+F6). It’s a feature called Quick Switch Editor and it makes working with editors a lot more enjoyable.

Quick Switch Editor works by popping up a list of all open editors (sorted by editor title) to the right of the editors tabs. The list is searchable so you don’t have to navigate long lists with the arrow key and searching supports wildcards. On top of that, you can also close editors from the list. Here’s a quick glimpse of what it looks like:

How to switch between and activate editors

The list is opened by pressing Ctrl+E from anywhere in Eclipse. On the list you can either:

  • use the arrow keys to navigate to the editor you want and then press Enter, or
  • search for and filter the list by editor name (with an optional wildcard) and press Enter once you found it.

This example video shows how easy it is to use, using both the arrow keys and the search and filter.

Notes:

  • The list is helpfully sorted by Editor title (usually the name of the file).
  • You have to use * for a wildcard search. Personally, I think Eclipse should have done an implicit wildcard search since I normally remember only partial editor names. (AutoHotkey users: Map Ctrl+E to insert a * after Ctrl+E is pressed if you like implicit wildcards; remember to apply only to the Eclipse window)

How to close editors

Once you’ve opened the list (Ctrl+E) and highlighted an editor, you can close it by pressing Delete (don’t worry, this will only close it, not delete it). Press Escape to close the list.

Here’s an example of how easy it is to close editors:

Eclipse keeps the list open if you’ve closed an editor so you can close as many other editors after that as you like. This works brilliantly if you have 20 editors open and now only want to keep 5 of them open. A tiny gotcha to watch out for is when you close the current active editor, Eclipse closes the list, so you’ll have to reopen it with Ctrl+E. Not too bad, but could’ve worked better.

So how is this faster than other ways of managing editors?

The Quick Switch Editor is a way to manage small to large amount of editors using the keyboard. So it’s faster to use when you’re busy editing code with the keyboard as opposed to browsing or navigating code with the mouse. You can also search for an editor by name – something you can’t do with the mouse.

It handles large amount of editors better than cycling through editors with the frustrating Ctrl+F6 (just try using Ctrl+F6 with 10 editors open and you’ll see what I mean, nevermind if you accidentally cycle past the editor you want). Ctrl+F4 (or Ctrl+W on Windows) also closes an editor but only after you’ve activated it. With Quick Switch Editor you can close any editor from the list. It’s also better than Switch to Editor (Ctrl+Shift+E) that shows a dialog listing all the editors, but doesn’t allow searching and isn’t as keyboard-friendly.

Tip: Keep yourself sane and remap Ctrl+F6 to Ctrl+Tab. This is really helpful when you’re frequently switching between the same two editors. Remap “Next Editor” under Window > Preferences > General > Keys.

Related Tips

Support Eclipse On E

Comments are closed.