Eclipse Shortcuts

 

This article lists helpful Eclipse shortcuts. It is based on Eclipse 4.2 (Juno).


1. Shortcuts

1.1. Using shortcuts in Eclipse

Using shortcuts make a developer more productive. Eclipse provides keyboard shortcuts for the most common actions. Using shortcuts is usually preferable as you can perform actions much faster.

Eclipse supports of course the typical shortcuts, e.g. Ctrl+S for saving, Ctrl+C for copying the selected text or file and Ctrl+V for pasting the element currently in the clipboard.

1.2. Shortcuts on Mac OS

This description uses the shortcuts based on Windows and Linux. Mac OS uses the Cmd key frequently instead of the Ctrl key.

2. Quick Access

The Ctrl+3 shortcut allows you to perform all available actions in Eclipse. This shortcut puts the focus into the Quick Access search box which allows you to execute any Eclipse command.

For example you can open a Preference, a Wizard, a view and a Preference page.

You can also use Quick Access to search for an opened editor by typing in the name of the resource which the editor shows.

The following screenshot shows how you could use Ctrl+3 to open the Wizard to create a new Java class.

 

Ctrl+3 shortcut dialog

 

3. Navigation

3.1. Globally available navigation shortcuts

Eclipse provides shortcuts for opening files or Java artifacts.

 

Table 1. Navigation

Shortcut Description
Ctrl + Shift + R Search dialog for resources, e.g. text files
Ctrl + Shift + T Search dialog for Java Types
Ctrl + E Search dialog to select an editor from the currently open editors
Ctrl + F8 Shortcut for switching perspectives

 

3.2. Navigation shortcuts in the editor

If you are working in the Java editor you can also use certain shortcuts for faster navigation. The following tables lists a few of them.

 

Table 2. Search from an editor

Shortcut Description
F3 Opens editor to selected element (type) or navigate to the declaration of the selected variable
Ctrl + . Go to the next problem / error
Ctrl + , Go to the previous problem / error
F4 on a variable Show type hierarchy
Ctrl + J Incremental search without popup dialog, just starting typing to search. Press Ctrl + J to find the next match
Ctrl + K Searches the selected text or if nothing is selected the last search from the Find dialog.
Ctrl + Shift + G In the Java editor, search for references in the workspace
Ctrl + Shift + P Select the matching bracket. Cursor needs to be placed before or after a bracket.

 

 

Table 3. Navigation between editors

Shortcut Description
Alt + ← Go to previous opened editor. Cursor is placed where it was before you opened the next editor
Alt + → Similar Alt + ← but opens the next editor
Ctrl + Q Go to editor and the position in this editor where the last edit was done
Ctrl + PageUp Switch to previous opened editor
Ctrl + PageDown Switch to next opened editor

 

4. Start Java programs

 

Table 4. Running programs

Shortcut Description
Ctrl + F11 Run last launched
Alt + Shift + X, J Run current selected class as Java application

 

5. Editing

The following lists contains useful keyboard shortcuts if you are inside your Java editor.

 

Table 5. Handling the editor

Shortcut Description
Ctrl + 1 Quickfix; result depending on cursor position
Ctrl + Space Content assist/ code completion
Ctrl + T Show the inheritance tree of the current Java class or method.
Ctrl + O Show all methods of the current class, press Ctrl + O again to show the inherited methods.
Ctrl + M Maximize active editor or view
Ctrl + Shift + F Format source code
Ctrl + I Correct indentation, e.g. format tabs/whitespaces in code
Ctrl + F Opens the find dialog
Ctrl + Shift + O Organize the imports; adds missing import statements and removes unused ones
Ctrl + Alt + Z Wrap the select block of code into a block, e.g. try/catch.

 

 

Table 6. Cursor navigation and text selection

Shortcut Description
Ctrl + ← or Ctrl + → Move one text element in the editor to the left or right
Ctrl + ↑ or ↓ Scroll up / down a line in the editor
Ctrl + Shift + P Go to the matching bracket
Shift + Cursor movement Select text from the starting position of the cursor
Alt + Shift ↑ / ↓ Select the previous / next syntactical element
Alt + Shift ↑ / ↓ / ← / → Extending / reducing the selection of the previous / next syntactical element

 

 

Table 7. Copy and move lines

Shortcut Description
Ctrl + Alt + Cusor Down Copy current line below the line in which the cursor is placed
Ctrl + Alt + Cusor Up Copy current line above the line in which the cursor is placed
Alt + Up Move line one line up
Alt + Down Move line one line down

 

 

Table 8. Delete

Shortcut Description
Ctrl + D Deletes line
Ctrl + Shift + DEL Delete until end of line
Ctrl + DEL Delete next element
Ctrl + BACKSPACE Delete previous element

 

 

Table 9. Create new lines

Shortcut Description
Shift + Enter Adds a blank line below the current line and moves the cursor to the new line. The difference between a regular enter is that the currently line is unchanged, independently of the position of the cursor.
Ctrl+Shift+Enter Same as Shift + Enter but above

 

 

Table 10. Variable assignment

Shortcut Description
Ctrl + 2, L Assign statement to new local variable
Ctrl + 2, F Assign statement to new field

 

6. Coding

 

Table 11. Coding

Shortcut Description
Shift + F2 Show the Javadoc for the selected type / class / method
Alt+Shift + N Shortcut for the menu to create new objects
Alt + Shift + Z Surround block with try and catch

 

7. Refactoring

 

Table 12. Refactoring

Shortcut Description
Alt + Shift + R Rename
Ctrl + 2, R Rename locally (in file), faster than Alt + Shift + R
Alt + Shift + T Opens the context-sensitive refactoring menu, e.g. displays

 

8. Minimum

The following shortcuts are the absolute minimum a developer should be familiar with to work efficient in Eclipse.

 

Table 13. Must known shortcuts

Shortcut Description
Ctrl + S Saves current editor
Ctrl + 1 Quickfix; shows potential fixes for warnings, errors or shows possible actions
Ctrl + Space Content assist/ code completion
Ctrl + Q Goes to the last edited position
Ctrl+ D Deletes current line in the editor
Ctrl + Shift + O Adjusts the imports statements in the current Java source file
Ctrl + 2, L or F Assign statement to new local variable or field
Ctrl + Shift + T Open Type Dialog
Ctrl + O Shows quick outline of a class
Ctrl + F11 Run last launched application

 

9. Links and Literature

9.1. Source Code

Source Code of Examples

JUnit Tutorial Test your application

Git Tutorial Put all your files in a distributed version control system