Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Useful Eclipse features? [closed]

Tags:

eclipse

People also ask

What are the features of Eclipse?

Features Of Eclipse IDEProvides excellent visual code debugging tool to debug the code. Eclipse has a wonderful user interface with drag and drop facility for UI designing. Supports project development and administered framework for different toolchains, classic make framework, and source navigation.

What does Ctrl Shift F do in Eclipse?

Show activity on this post. Ctrl + Shift + F formats the selected line(s) or the whole source code if you haven't selected any line(s) as per the formatter specified in your Eclipse, while Ctrl + I gives proper indent to the selected line(s) or the current line if you haven't selected any line(s).


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

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.


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.


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.


Ctrl-Alt (up/down) Copy selected line(s) above or below current line.
Alt (up/down) Move current (or multiple selected) lines up or down
Ctrl-Shift-R Bring up the resource window, start typing to find class/resource
Ctrl-O Bring up all methods and fields for the current class. Hitting it again will bring up all methods and fields for current class and super classes.
Ctrl-/ or Ctrl-Alt-C Comment single or multiple lines with //
Ctrl-Shift-/ Comment selected lines with /* */
Ctrl-. Take you to the next error or warning line


CTRL+PAGE DOWN / CTRL+PAGE UP to switch between opened editors

CTRL+E to also switch between opened editors (allows to type the name)

CTRL+O is extremely important for me. You don't longer need the Outline View then (you can close it which will give you more space). Then, you can type a method name or just the beginning of it and you quickly can get to it. I also use it to inspect what stuff is available. For example: CTRL+O and then type get ... now I see all getters.

F3 while an element is selected in the code: brings you to its definition or it's source. e.g. used on a method call it brings you into the source code of that method.

CTRL+M to maximize the current window

As already said, CTRL+3 is extremely good. It basically allows you to use Eclipse completely without a mouse. Just type CTRL+3 and then package explorer for example.

CTRL+F8 cycle trough perspectives

CTRL+L allows to type a line number and brings you directly to that line.

CTRL+SHIFT+G searches for all references to the selected element in the workspace.

And not a shortcut: In the project settings under Java Editor you can find Save Actions. This allows you to set up the project so that the code is automatically cleaned up and formatted when you save a file. That's very good it safes you from constantly pressing CTRL+O and CTRL+F.


Eclipse auto refresh isn't on by default so if you make changes to a file outside of eclipse, the change won't be reflected in your build. this is very annoying if you just did an svn/git update/rebase and things aren't working the way they're supposed to.

Turn it on in windows->preferences->workspace and tick Refresh Automatically.