Ctrl-1 is the magic “do what I think” button in Eclipse. Whenever I press it, Eclipse seems to come up with something that’s helpful in the current context. In this blog post, I illustrate 10 things that Eclipse hide under the ctrl-1 keypress. This is a follow up on my post on Eclipse stenography.
I got some comments on my last post about Eclipse stenography about the animated gifs. I know this can be annoying, but I considered the alternative: To have you mouse-over or click a picture to animate it. I’m afraid that the pictures will sort of disappear from your attention if I do this. So I’ll try again. But this time, I’ll put the images below the fold. Click on to see the ten tips.
1: Create a class that you refer to in existing code
2: If you create a class and Eclipse detects that it must implement an interface, Eclipse will generate stub implementations of the interface for you
3: As above: If you code references a non-existing constructor, Eclipse can create it for you
4: And if a parameter to a constructor or method is unused, Eclipse can create a new field and assign the parameter to it
5: When the cursor is on an expression, Eclipse can assign the expression to a local variable
6: If you’re comparing two values, and only one can be null, Eclipse can invert the objects to avoid the null
7: Eclipse can help you massage a conditional expression into shape
8: Convert old style loops to fancy new loops, where possible
9: Take care of those annoying checked exceptions
On a related note, there’s only one thing I really hate about the Java language: Checked exceptions. They get in the way of code coverage, they trick novice developers to deal with problems locally instead of at the top level, and ultimately, they introduce more bugs. And that’s a fact!
10: When you have a field that’s just not being used, why not have Eclipse help you violate encapsulation with less work
What’s your favorite?
Eclipse (and other IDEs) have a myriad of smart tricks. For Eclipse, ctrl-space and ctrl-1 give you access to a surprising amount of functionality. Do you know any other keyboard shortcut that’s as versatile? Or as useful? Do share! :-)
To quote google: Did you mean: epilepsy therapy
Yikes the blinking! :)
LOL! It has been a tough choice to decide whether to “hide” the animations more. If you slow down and look at one picture at a time, I think it’s pretty useful. But when you look at the whole page, it may be epilepsy inducing.
Crtl-3 shows a dialog where you can type any menu command, view or perspective to jump to, launch a preference pane etc. Almost like Quicksilver/Launchy for Eclipse :-)
Nice. Definitely worth learning.