Friday, October 12, 2012

Eclipse Tips

I mainly use Visual Studio for development in the past 8 years. Recently I switch to Eclipse to do some Android work. Not like old days I had to spend a lot of time on memorizing a list of commands to run the vi editor, modern IDEs are quite easy to work with, but the right settings and handy short-cuts can still speed up your work. Below is some of my findings on Eclipse that helps me to do my work more efficiently.

Preference Settings:

1. Show code line number:

I am not sure why both Eclipse and Visual Studio are not showing line number by default. The line number is quite useful for me to pin point the source code, so I turn it on the first place.

2. Save before build but not automatically build.

Unlike Visual Studio Eclipse will not save your changes when you click build or run the application. On the other hand, Eclipse automatically build(compile) the source files in the background every time you make a change in source file. I don't like both default options and here is where you can change the behavior:

3. Enable auto insert:

This is a nice feature in Eclipse which is not available in Visual Studio or I am not aware of. Basically you can type ";" or "{" anywhere during coding and Eclipse will automatically put it to the right spot, the ending of the code line.

4. Enable step filters:

With “Step Filters” you will skip stepping into those types during debugging, so you could just focus on your own code.

Handy short-cuts

Ctrl+Space content assist just like intellisense in Visual Studio
Ctrl+Shift+F format code
Ctrl+/ comment/uncomment code with //
Ctrl+Shift+/ comment code with /**/
Ctrl+D delete line
F3 go to declaration
Ctrl+Shift+O auto import (when this available in Visual Studio?)
Ctrl+T show type hierarchy
Ctrl+Shift+T search for type
Ctrl+Shift+R search for resource
Ctrl+Shift+G find all references
Ctrl+H open advanced search window
Alt+Left/Right navigate source back and forward like Ctrl-/+ in Visual Studio