I’m pretty happy working in Eclipse. Today I’ll share one of my favorite “workhorse” keyboard shortcuts.
So say you’re editing some unit tests (you are writing unit tests, right?) for a particular class and you want to run them. Of course, you’ve set up a launch to run all the tests in your project, but you have so many tests that you don’t want to sit through them all for this one little test. Try this instead:
alt+shift+X and then T
Yay the tests in the current file were just run. So let’s decode that. “alt+shift+X”. X is for eXecute. Now what is “T” for? Oh yeah, Test. Execute test. That’s way faster than right-click, run as, JUnit test, etc. Or finding the JUnit view and clicking “run again”.
Now what if you wanted to debug? I can guess that the shortcut will end with a “T”. What does it start with though?
alt+shift+D and then T
Nice. So “alt+shift+D” means debug.
Ok, now if I’m just editing a plain old Java file with a main() method, i.e. I’m testing by hand (bad boy!) what should I do?
alt+shift+X and then J
Of course it starts with execute, and then “J” for Java. Similarly, if I want to debug:
alt+shift+D and then J
Cool. Now do that a few hundred times until it’s in muscle memory and you stop using your mouse like a sucker.
Note that these shortcuts not only work in the active editor, but on selected resources. Select a class in the Package Explorer and try it out.
So now you’re starting your debug session without the mouse. Don’t waste your time clicking those step buttons:
- Step Into – F5
- Step Into Selection – Ctrl+F5
- Step Over – F6
- Step Return – F7
- Resume – F8
I have to admit these have been harder to get down after so many years in Visual Studio. Way it goes.
p.s. I realize these are kind of obvious, but sometimes I don’t do something unless someone tells me to, which may hold for others as well. :) Also there are actually shorter shortcuts for things like debugger (F11 I think), but I like mnemonics.