Easy Tutorial
❮ Eclipse Search Menu Eclipse Running Program ❯

Eclipse Keyboard Shortcuts

About Keyboard Shortcuts

Eclipse provides many operations with keyboard shortcuts, allowing us to control various functions of Eclipse through the keyboard:

The list of Eclipse shortcuts can be opened with the shortcut Ctrl + Shift + L.


Setting Keyboard Shortcuts

Sometimes, the default shortcuts provided by Eclipse are hard to remember, or they may not be provided at all, requiring manual setup.

We can access the keyboard shortcut management interface by clicking window -> preferences -> general -> keys (or simply search for "keys"):

Here, you can find shortcuts for all functions. To modify or add a shortcut, click the command you want to change or add, and set the shortcut in the binding field:

After setting the shortcut, you also need to specify when it can be used. Eclipse offers various scenarios to choose from; generally, selecting "In Windows" (i.e., when the Eclipse window is active) is sufficient.

Click the OK button to complete the setup.


Common Eclipse Shortcuts

Shortcut Description
Edit
---
Ctrl+1 Quick fix (a classic shortcut that can solve many issues, such as importing classes, surrounding with try-catch, etc.)
Ctrl+Shift+F Format the current code
Ctrl+Shift+M Add import for the class
Ctrl+Shift+O Organize imports (it not only adds imports but also removes unused ones, very useful)
Ctrl+Y Redo (opposite of undo with Ctrl+Z)
Alt+/ Content assist (saves a lot of keystrokes, very commonly used)
Ctrl+D Delete the current line or multiple lines
Alt+↓ Swap the current line with the next one (very practical, saves the need to cut and paste)
Alt+↑ Swap the current line with the previous one (same as above)
Ctrl+Alt+↓ Copy the current line to the next line (copy and increment)
Ctrl+Alt+↑ Copy the current line to the previous line (copy and increment)
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 the current line, press again to uncomment
Select
---
Alt+Shift+↑ Select encapsulation elements
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
Move
---
Ctrl+← Move the cursor to the beginning of the left word, equivalent to 'b' in vim
Ctrl+→ Move the cursor to the end of the right word, equivalent to 'e' in vim
Search
---
Ctrl+K Quickly locate the next occurrence of the selected word (if no word is selected, it searches for the last used word)
Ctrl+Shift+K Quickly locate the previous occurrence of the selected word
Ctrl+J Incremental forward search (after pressing Ctrl+J, each letter you type quickly matches and locates a word; if none is found, it shows "not found" in the status bar; very useful for searching a word, press escape to exit this mode)
Ctrl+Shift+J Incremental backward search (same as above, but searches backward)
Ctrl+Shift+U List all lines containing the string
Ctrl+H Open the search dialog
Ctrl+G Declarations in the workspace
Ctrl+Shift+G References in the workspace
Navigate
---
Ctrl+Shift+T Search for classes (including projects and associated third-party JARs)
Ctrl+Shift+R Search for files in the project
Ctrl+E Quickly display the dropdown list of the current editor (files not displayed are shown in bold)
F4 Open type hierarchy
F3 Jump to the declaration
Alt+← Previous edited page
Alt+→ Next edited page (relative to the previous one)
Ctrl+PageUp/PageDown Switch between open files in the editor
Debug
---
F5 Step into
F6 Step over
F7 Step out
F8 Continue
Ctrl+Shift+D Display the value of the variable
Ctrl+Shift+B Set or remove breakpoint at the current line
Ctrl+R Run to Line (Super useful, saves a lot of breakpoints)
Refactor (Common refactoring shortcuts usually start with Alt+Shift)
---
Alt+Shift+R Rename method, property, or variable (My personal favorite, especially for renaming variables and classes, saves a lot of manual work)
Alt+Shift+M Extract method from a block of code (One of the most commonly used refactoring methods, especially useful for a large block of tangled code)
Alt+Shift+C Modify function structure (Quite practical, if N functions call this method, modify it once to fix all)
Alt+Shift+L Extract local variable (Can directly extract some magic numbers and strings into a variable, especially when called multiple times)
Alt+Shift+F Convert local variable in a class to field variable (A practical feature)
Alt+Shift+I Inline variable (Might not be the best term for it)
Alt+Shift+V Move function and variable (Not commonly used)
Alt+Shift+Z Refactoring undo (Undo)
Other
---
Alt+Enter Show properties of the selected resource, the same shortcut for viewing file properties in Windows, often used to check the actual path of a file in Windows
Ctrl+↑ Text editor scroll up
Ctrl+↓ Text editor scroll down
Ctrl+M Maximize current Edit or View (Press again to revert)
Ctrl+O Quickly display Outline (Essential for those who don't open the Outline window)
Ctrl+T Quickly display inheritance structure of the current class
Ctrl+W Close current Editor (Same for closing dialogs in Windows, and also for QQ, Wangwang, browsers, etc.)
Ctrl+L Text editor go to line
F2 Show tool tip description
❮ Eclipse Search Menu Eclipse Running Program ❯