Copyright © 2009, 2010, 2011, 2012, 2013 vogella GmbH
Table of Contents
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.
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.
Eclipse provides shortcuts for opening files or Java artifacts.
Table 1. Navigation
|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|
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
|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, s\earch 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
|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|
Table 4. Running programs
|Ctrl + F11||Run last launched|
|Alt + Shift + X, J||Run current selected class as Java application|
The following lists contains useful keyboard shortcuts if you are inside your Java editor.
Table 5. Handling the editor
|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
|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
|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
|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
|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
|Ctrl + 2, L||Assign statement to new local variable|
|Ctrl + 2, F||Assign statement to new field|
Table 11. Coding
|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|
Table 12. Refactoring
|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|
The following shortcuts are the absolute minimum a developer should be familiar with to work efficient in Eclipse.
Table 13. Must known shortcuts
|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|
Writing and updating these tutorials is a lot of work. If this free community service was helpful, you can support the cause by giving a tip as well as reporting typos and factual errors.
If you find errors in this tutorial, please notify me (see the top of the page). Please note that due to the high volume of feedback I receive, I cannot answer questions to your implementation. Ensure you have read the vogella FAQ as I don't respond to questions already answered there.
|TRAINING||SERVICE & SUPPORT|
|The vogella company provides comprehensive training and education services from experts in the areas of Eclipse RCP, Android, Git, Java, Gradle and Spring. We offer both public and inhouse training. Whichever course you decide to take, you are guaranteed to experience what many before you refer to as “The best IT class I have ever attended”.||The vogella company offers expert consulting services, development support and coaching. Our customers range from Fortune 100 corporations to individual developers.|