Eclipse Shortcuts
About Shortcuts
Many operations in Eclipse provide shortcuts, which let us control the various features of Eclipse well through the keyboard:
- Use shortcuts to associate a menu or menu item
- Use shortcuts to associate a dialog, view, or editor
- Use shortcuts to associate a toolbar button
The Eclipse shortcut list can be opened with the shortcut Ctrl + Shift + L.
Setting Shortcuts
The shortcuts provided by Eclipse can sometimes be hard to remember, or may not be provided at all, in which case you need to set them manually.
We can enter the shortcut management interface by clicking window -> preferences -> general -> keys (or directly searching for keys):
Here you can find the shortcuts for all functions. To modify or add one, click the command you want to modify or add and set the shortcut in binding: 
After setting the shortcut, you also need to set when the shortcut can be used. Eclipse provides various scenarios to choose from; generally selecting In Windows (i.e., when the Eclipse window is active) is fine.
After completing the above steps, click the OK button to finish the setup.
Common Eclipse Shortcuts
| Keyboard shortcut | Description |
|---|---|
| Editing | |
| Ctrl+1 | Quick Fix (the most classic shortcut, no need to say more; it can solve many problems, such as importing classes, surrounding with try/catch, etc.) |
| Ctrl+Shift+F | Format the current code |
| Ctrl+Shift+M | Add imports for the class |
| Ctrl+Shift+O | Organize imports for the class (it does the job of Ctrl+Shift+M and also removes unused imports; very useful) |
| Ctrl+Y | Redo (the opposite of undo Ctrl+Z) |
| Alt+/ | Content Assist (saves you countless keystrokes; extremely common) |
| Ctrl+D | Delete the current line or multiple lines |
| Alt+↓ | Swap the current line with the one below (very handy; saves you from cutting and pasting) |
| Alt+↑ | Swap the current line with the one above (same as above) |
| Ctrl+Alt+↓ | Copy the current line to the line below (duplicate) |
| Ctrl+Alt+↑ | Copy the current line to the line above (duplicate) |
| Shift+Enter | Insert a blank line below the current line (the cursor can be anywhere in the current line, not necessarily at the end) |
| Ctrl+/ | Comment out the current line; press again to uncomment |
| Choice | |
| Alt+Shift+↑ | Select the enclosing element |
| Alt+Shift+← | Select the previous element |
| Alt+Shift+→ | Select the next element |
| Shift+← | Select characters to the left from the cursor |
| Shift+→ | Select characters to the right from the cursor |
| Ctrl+Shift+← | Select the word to the left of the cursor |
| Ctrl+Shift+→ | Select the word to the right of the cursor |
| Mobile | |
| Ctrl+← | Move the cursor to the beginning of the word on the left, equivalent to vim's b |
| Ctrl+→ | Move the cursor to the end of the word on the right, equivalent to vim's e |
| Search | |
| Ctrl+K | Quickly locate the next occurrence based on the selected word (if no word is selected, search for the last searched word) |
| Ctrl+Shift+K | Quickly locate the previous occurrence based on the selected word |
| Ctrl+J | Forward incremental search (after pressing Ctrl+J, every letter you type makes the editor quickly match and locate a word; if none is found, the status bar shows not found. Very useful when searching for a word. To exit this mode, press the escape key) |
| Ctrl+Shift+J | Reverse incremental search (same as above, but searches backward) |
| Ctrl+Shift+U | List all lines containing a string |
| Ctrl+H | Open the Search dialog |
| Ctrl+G | Declarations in the workspace |
| Ctrl+Shift+G | References in the workspace |
| navigation | |
| Ctrl+Shift+T | Search classes (including the project and associated third-party jars) |
| Ctrl+Shift+R | Search files in the project |
| Ctrl+E | Quickly display the drop-down list of the current Editor (items not shown on the current page are displayed in bold) |
| F4 | Open the Type Hierarchy |
| F3 | Jump to the declaration |
| Alt+← | The previous edited page |
| Alt+→ | The next edited page (of course, relative to the one above) |
| Ctrl+PageUp/PageDown | Switch between already open files in the editor |
| Debugging | |
| F5 | Step Into |
| F6 | Step Over |
| F7 | Step Return |
| F8 | continue |
| Ctrl+Shift+D | Display the value of a variable |
| Ctrl+Shift+B | Set or remove a breakpoint on the current line |
| Ctrl+R | Run to Line (super useful; saves a lot of breakpoints) |
| Refactor (most refactoring shortcuts start with Alt+Shift) | |
| Alt+Shift+R | Rename a method name, property, or variable (my personal favorite, especially renaming variables and classes, which saves a lot of labor compared to doing it manually) |
| Alt+Shift+M | Extract code from a function into a method (one of the most commonly used refactorings, especially useful for a big ball of mud code) |
| Alt+Shift+C | Change the function structure (practical; if N functions call this method, change it once and you're done) |
| Alt+Shift+L | Extract a local variable (you can directly extract magic numbers and strings into a variable, especially when used in multiple places) |
| Alt+Shift+F | Change a local variable in a Class into a field variable (a pretty practical feature) |
| Alt+Shift+I | Merge variables (maybe not the best way to put it; Inline) |
| Alt+Shift+V | Move functions and variables (not commonly used) |
| Alt+Shift+Z | The undo pill for refactoring (Undo) |
| Others | |
| Alt+Enter | Show the properties of the currently selected resource; in Windows, viewing file properties uses this shortcut, usually to see the actual path of a file in Windows |
| Ctrl+↑ | Text editor scroll line up |
| Ctrl+↓ | Text editor scroll line down |
| Ctrl+M | Maximize the current Edit or View (press again to restore) |
| Ctrl+O | Quickly display OutLine (essential for those who don't open the Outline window) |
| Ctrl+T | Quickly display the inheritance structure of the current class |
| Ctrl+W | Close the current Editer (in Windows this also closes an open dialog, and is used by qq, WangWang, browsers, etc.) |
| Ctrl+L | Text editor Go to Line |
| F2 | Show tool tip description |