Alex Rivera | Logout

Hidden features of Eclipse

Asked 2008-09-10T18:05:39.977
97

Alright it can be a lame question, but everybody uses these things differently. What's some of the best time savers out there for this IDE.

Tom

Edit
Report

13 Answers

81

ctrl-shift-r and its buddy, ctrl-shift-t, to open a resource or type, respectively. Resources includes all files in your open projects (including non-java files), and types includes java types either in your projects, or in a library included in the projects.

answered 2008-09-10T18:21:07.367
37

Type 'syso' then press Ctrl+Space to expand it to System.out.println().

Tres handy.

answered 2008-09-16T09:29:29.573
28

Clicking on the return type in a method's declaration highlights all exit points of the method.

for instance:

1: public void foo()
2: {
3:   somecode();
4:    if ( blah ) return;
5:
6:    bar();
7: }

clicking on void will highlight the return on line 4 and the close } on line 7.

Update: It even works for try{} catch blocks. If you put cursor on exception in the catch block and eclipse will highlight the probable methods which may throw that exception.

answered 2009-09-02T18:26:41.093
20

Hippie expand/Word Complete, afaik inspired by Emacs: will autocomplete any word in any editor based on other words in that file. Autocomplete inside String literals in Java code, in xml files, everywhere.

Alt + /

answered 2008-09-12T10:51:26.213
15

Ctrl + Shift + M: changes a static method or static attribute reference of a class to a static import.

Before

import X;

...
X.callSomething();

After

import static X.callSomething;

...
callSomething();
answered 2010-06-10T12:15:27.710
4

Ctrl + Shift + P to find the matching brace. Really useful while working with long codes.

answered 2009-03-17T06:07:51.677
3

You can CTRL-click on just about any type, field, method, or variable and eclipse will bring you to the declaration of that item:

ie:

  • on a local variable - brings you to the declaration statement in the function
  • on a member variable - brings you to the definition in a class file that the member is declared (or the parent class if it's not overridden in a child class
  • on a class - brings you to the top of the class file for that class

You can also CTRL-hover over a type to bring up the option to find an implementation. This is useful if you are using an interface and want to see what classes implement that interface. It also works to see what super-classes and subclasses might implement/override a certain function.

answered 2010-07-01T17:30:56.683
2

ctrl-alt-up/down to copy a line up (or down). That followed by alt-up/down is often much quicker than a copy-paste

answered 2008-10-22T14:07:50.467
2

Ctrl + H searches/replaces through the whole workspace or project.

answered 2010-03-06T17:24:17.643
1

When debugging I find the "Display" view really useful. It lets you type code (using auto complete) and lets you run/display the outcome of whatever you write.

Give it a try!

answered 2008-09-19T02:34:59.030
1

Ctrl-1 to convert if to conditional expression and back, split an assignment or join it back or do other such small manipulations. There is a list of these in the help.

answered 2008-10-14T17:25:37.840
0

Of course if you can't find the binding you are looking for, or don't like the current binding Window -> Preferences -> General -> Keys will allow you to change, add & delete the mappings of your key combo's.

answered 2008-10-14T00:06:54.240
0

I'm really biased and this is blatant advertising...

Still, I think my new Eclipse plugin, nWire, is the best time saver you can get for Eclipse. I developed it after years of working with Eclipse, I just came to the conclusion that I need one tool to show me all the associations of my code instead of learning different tools and views.

Check out the demo on my web site.

answered 2009-02-27T06:27:08.337

Your Answer