Among many blog posts and articles on „Eclipse Tips & Tricks” I haven’t found any related to effectively managing tabs and closing unused ones. I decided to write one myself as it is an issue developers face every day.
Why close unused tabs?
If it comes to tabs management, I’ve met two types of people:
- Those who close unnecessary tabs once in a while
- Those who don’t care and work with a ridiculous amount of tabs (I’ve seen over 100 tabs open in Eclipse!)
Regrettably, the second group seem to prevail. Why? You want to open a file – you need a new tab, fine enough. But it’s hard to think of situation that enforces closing a tab.
I observed that I really work with 2-3 editors on average. The rest of open tabs is a side effect of code exploration; these are tabs that I open once to e.g. check a definition of method and then I don’t need any longer
So how to quickly close unnecessary tabs in Eclipse?
There are five ways that I regularly use to clean up unused tabs in Eclipse:
- Closing tabs one by one by clicking on the tab with a wheel/MMB. It’s faster than clicking LMB on a small cross icon, because it’s enough to click anywhere on a surface of a tab. I do it when there is few tabs to close (like one or two) and tabs that I want to close aren’t hidden.
- Closing current tab using Ctrl+W keystroke. I do when tab to be closed happens to be an active tab. And when I just visited some class to check something and I won’t need to revisit it anymore soon.
- Using Ctrl+Shift+W keystroke to close all tabs. I do it when I’m starting completely new tasks or at the moment I’m too lazy for 4. or 5. .
- Right-clicking on the tab that should stay open and selecting “Close all others” option. It’s handy in cases where only one editor is significant and others are a result of code exploration.
- This is my favourite one: Using ctrl+shift+e keystroke to display “Open editors” dialog, selecting editors that should stay open (with ctrl pressed), “invert selection”, “close all selected” and finally hitting esc to close the dialog. It may seem complex but trust me it isn’t. It took me only a few attempts to learn how to use this trick effectively. I often do it when I forgot to close tabs for a while and I have a lot of tabs open and what’s worse, some of tabs aren’t visible on tabs bar (arrow icon needs to be clicked to see the hidden tabs).
As humans, we can’t wrap our heads on too many things at the same time. Let’s use our tools wisely, so that we can only focus on what is really important.