Useful Eclipse features? [closed]

I have been using Eclipse as an IDE for a short amount of time (about 3 months of full use) and almost every day I learn about some shortcut or feature that I had absolutely no idea about. For instance, just today I learned that Ctrl+3 was the shortcut for a Quick Access window.

I was wondering what your most useful/favorite Eclipse features are. With the IDE being so big, it would be helpful to learn about the more commonly used parts of the program.


Solution 1:

My most commonly used features are

ctrl+1 quick-fix / spell-checker

opening files

  • ctrl+shift+t load class file by classname
  • ctrl+shift+r load any file by filename

matches are made on the start of the class/filename. start your search pattern with a * to search anywhere within the filename/classname.

Formatting

  • ctrl+shift+f Format source file (set up your formatting style in Window | preferences | java | code style | formatter)
  • ctrl+shift+o Organise imports

Generated code

  • alt+s,r to generate getters and setters
  • alt+s,v to insert method signatures for overidden methods from superclass or interface

Refactorings

  • alt+shift+l Extract text-selection as local variable (really handy in that it determines and inserts the type for you.
  • alt+shift+m Extract text-selection as a method
  • alt+shift+i inline selected method

Running and debugging.

alt+shift+x is a really handy prefix to run stuff in your current file.

  • alt+shift+x, t run unit tests in current file
  • alt+shift+x, j run main in current file
  • alt+shift+x, r run on server

There are more. The options are shown to you in the lower-right popup after hitting alt+shift+x.

alt+shift+x can be switched for alt+shift+d in all the above examples to run in the debugger.

Validation

As of the recent Ganymede release, you can now switch of validation in specified files and folders. I've been waiting for this feature for ages.

  • Go to Project | Properties | Validation
  • click on the ... button in the settings column of the validator you want to shut up
  • Add a rule to the exclude group

code navigation

  • hold down ctrl to make all variables, methods and classnames hyperlinks to their definitions.
  • alt+left to navigate back to where you clicked ctrl
  • alt+right to go "forwards" again

Solution 2:

This is cool: If someone has emailed you a stack trace, you can copy and paste the stack trace into Eclipse's Console window. You can then click on class names in the stack trace as if your own code had generated it.

Solution 3:

In terms of actual features, rather than shortcuts, I strongly recommend taking a look at Mylyn.

It essentially skins Eclipse with a task focussed view. It tracks the files you touch when working on a task, and focusses many aspects of the UI onto the resources that it decides are relevant to the job in hand. Eclipse can be somewhat busy to look at, especially with a big multi module project, and Mylyn helps cut through the cruft. The connectivity to issue tracking software and source control repositories is also excellent.

In my experience, it polarises opinion amongst those who try working with it, which is probably a sign that it is offering something interesting... Don't mean to sound like a fanboy - it is definitely worth a look though.

Solution 4:

A shortcut that I use everyday is Ctrl+K. In your editor (not only Java file), simply select a text (like a variable, a function, etc.), and then use this shortcut to go to the next occurrence of this text in the current editor. It's faster than using the Ctrl+F shortcut...

Note also that you can use Ctrl+Shift+K to search backwards.