Using shortcuts in Eclipse

When working with any tools, not only Eclipse, using shortcut will help us save time compare to using mouse. In this tutorial, i will introduce some popular shortcuts in Eclipse!

Ctrl + D

When you want to delete one row, simply you only need leave your mouse on the row and press Ctrl + D. Selecting all the text in row and pressing Delete button will take your time.

Alt + Up | Down

Combination between Alt + Up or Alt + Down can help you move your code up or down to arrange them.

Example, I have a piece of code as below:

I want to move this line

up to top, I only need leave my mouse on this line, keep the key Alt and double press Up key.

Alt + Left | Right

Go to next place and previous place of code which we just edited.

Example, you just edited the code in class A and now you are working on class B. If you want go to the place that you just edited in class A, you only need press Alt + Left. After you went back to the place in class A, now you want to go back to class B, just press Alt + Right.

Ctrl + 1

This keys will active the function Quick fix of Eclipse.

One example about using the combination between Ctrl and 1 is: you initialize a new object by using the operator new.

Now, you want assign for this object reference to a variable. In this case, you only need leave your mouse at this line, press Ctrl + 1, one popup will be displayed as below:

Sử dụng phím tắt trong Eclipse

Select Assign statement to new local variable if you want assign your object into a reference variable as a local variable, or Assign statement to new field if you want this variable as a global variable.

Ctrl + Shift + O

Combination of this keys help us import all classes which are using in our class if they haven’t imported yet.

When you press this keys, all using classes will be imported and all non-using classes will be removed.

Ctrl + Shift + T

Using to search and open a class in our workspace. Quick and convenient!

Ctrl + Shift + F

Format our code.

Formatting code is very necessary for our code, it will help our code clearly, easy to read and maintenance. You can edit the setting of formatting code by: Window –> Preferences –> Java –> Code Style –> Formatter.

Ctrl + Shift + G

Search where the class or the method is using in our workspace.

Example I need to find out where the class A or method A is using in my workspace, simply I only need leave my mouse on the name of class or method, then press Ctrl + Shift + G, all reference to my class or my method will be displayed.

Add Comment