Editors are an integral part of programming. There are a lot of editors available; Eclipse has been a widely used Java IDE. Shortcuts make life much easier when you are working with any IDE. Below is a collected cheat sheet of the most useful Eclipse keyboard shortcuts for Windows and Linux. (Mac OS typically uses the Cmd key instead of Ctrl.)
Note: This page lists the shortcuts as the author wrote them. If you rely on a specific Eclipse release, verify shortcuts in your Eclipse key preferences.
Table of contents
- Notes
- 1. Manage Files and Projects
- 2. Editor Window
- 3. Navigate in Editor
- 4. Select Text
- 5. Edit Text
- 6. Search and Replace
- 7. Indentations and Comments
- 8. Editing Source Code
- 9. Code Information
- 10. Refactoring
- 11. Run and Debug
- 12. Others
Notes
- Shortcuts below are given for Windows and Linux. On macOS, replace
CtrlwithCmdwhere applicable. - The list is presented in the same grouping the author used so you can jump to categories quickly.
1. Manage Files and Projects
Ctrl+N: Create new project using the WizardCtrl+Alt+N: Create new project, file, class, etc.Alt+f, then.: Open project, file, etc.Ctrl+Shift+R: Open Resource (file, folder or project)Alt+Enter: Show and access file propertiesCtrl+S: Save current fileCtrl+Shift+S: Save all filesCtrl+W: Close current fileCtrl+Shift+W: Close all filesCtrl+P: Print the fileF5: Refresh content of selected element with local file system
2. Editor Window
Focus/cursor must be in the editor window for these to work.
F12: Jump to Editor WindowCtrl+PageDown/Ctrl+PageUp: Switch to next editor / previous editorCtrl+M: Maximize or minimize current editor window (also works for other windows)Ctrl+E: Show list of open editors (use arrow keys and Enter to switch)Ctrl+F6/Ctrl+Shift+F6: Show list of open editors; switches immediately upon release of CtrlAlt+←/Alt+→: Go to previous / next editor windowAlt+-: Open editor window option menuCtrl+F10: Show view menu (features available on left vertical bar: breakpoints, bookmarks, line numbers, …)Ctrl+F10, thenn: Show or hide line numbersCtrl+Shift+Q: Show or hide the diff column on the left (changes since last save)
3. Navigate in Editor
Home/End: Jump to beginning / end of indentation. Press Home twice to jump to beginning of lineCtrl+Home/Ctrl+End: Jump to beginning / end of sourceCtrl+←/Ctrl+→: Jump one word left / one word rightCtrl+Shift+↓/Ctrl+Shift+↑: Jump to previous / next methodCtrl+L: Jump to line number. (To hide/show line numbers:Ctrl+F10then select 'Show Line Numbers')Ctrl+Q: Jump to last location editedCtrl+./Ctrl+,: Jump to next / previous compiler syntax warning or errorCtrl+Shift+P: With a bracket selected: jump to the matching bracketCtrl+[+]/Ctrl+-on numeric keypad : Collapse / expand current method or classCtrl+[/]/Ctrl+*on numeric keypad : Collapse / expand all methods or classesCtrl+↓/Ctrl+↑: Scroll editor without changing cursor positionAlt+PageUp/Alt+PageDown: Next sub-tab / previous sub-tabCtrl+F7: Next ViewCtrl+Shift+F7: Previous ViewCtrl+F8: Next PerspectiveCtrl+Shift+F8: Previous PerspectiveCtrl+.: Go to the next problem / errorCtrl+,: Go to the previous problem / error
4. Select Text
Shift+→/Shift+←: Expand selection by one character right / leftCtrl+Shift+→/Ctrl+Shift+←: Expand selection to next / previous wordShift+↓/Shift+↑: Expand selection by one line down / upShift+End/Shift+Home: Expand selection to end / beginning of lineCtrl+A: Select allAlt+Shift+↑: Expand selection to current element (e.g., current one-line expression or content within brackets)Alt+Shift+←/Alt+Shift+→: Expand selection to next / previous elementAlt+Shift+↓: Reduce previously expanded selection by one step
5. Edit Text
Ctrl+C/Ctrl+X/Ctrl+V: Copy, Cut and PasteCtrl+Z: Undo last actionCtrl+Y: Redo last (undone) actionCtrl+D: Delete lineAlt+↑/Alt+↓: Move current line or selection up or downCtrl+Alt+↑/Ctrl+Alt+↓: Duplicate current line or selection up or down (note: on some Windows setups these shortcuts may rotate the screen)Ctrl+Delete: Delete next wordCtrl+Backspace: Delete previous wordShift+Enter: Enter line below current lineShift+Ctrl+Enter: Enter line above current lineInsert: Toggle between insert and overwrite modeShift+Ctrl+Y: Change selection to all lower caseShift+Ctrl+X: Change selection to all upper case
6. Search and Replace
Ctrl+F: Open find and replace dialogCtrl+K/Ctrl+Shift+K: Find previous / find next occurrence of search term (close find window first)Ctrl+H: Search workspace (Java Search, Task Search, and File Search)Ctrl+J/Ctrl+Shift+J: Incremental search forward / backwards (type search term after pressingCtrl+J)Ctrl+Shift+O: Open a resource search dialog to find any classCtrl+J: Incremental search without popup dialog; pressCtrl+Jto find the next matchCtrl+Shift+G: In the Java editor, search for references in the workspaceCtrl+Shift+P: Select the matching bracket (cursor needs to be before or after a bracket)
7. Indentations and Comments
Tab/Shift+Tab: Increase / decrease indent of selected textCtrl+I: Correct indentation of selected text or current lineCtrl+Shift+F: Autoformat all code in editor using code formatterCtrl+/: Comment / uncomment line or selection (adds//)Ctrl+Shift+/: Add block comment around selection (adds/* ... */)Ctrl+Shift+\: Remove block commentAlt+Shift+J: Add element comment (adds/** ... */)
8. Editing Source Code
Ctrl+Space: Opens Content Assist (show available methods, fields, etc.)Ctrl+1: Open Quick Fix and Quick AssistAlt+/: Propose word completion (after typing at least one letter; press repeatedly to cycle options)Ctrl+Shift+Insert: Deactivate or activate Smart Insert Mode (automatic indentation, automatic brackets, etc.)
9. Code Information
Ctrl+O: Show code outline / structureF2: Open class, method, or variable information (tooltip text)F3: Open Declaration — jump to declaration of selected class, method, or parameterF4: Open Type Hierarchy window for selected itemCtrl+T: Show / open Quick Type Hierarchy for selected itemCtrl+Shift+T: Open Type in HierarchyCtrl+Alt+H: Open Call HierarchyCtrl+U: Find occurrences of expression in current fileCtrl+move over method: Open Declaration or Implementation (hover and Ctrl+click behavior)
10. Refactoring
Alt+Shift+R: Rename selected element and all referencesAlt+Shift+V: Move selected element to other class or file (with complete method or class selected)Ctrl+Shift+C: Change method signature (with method name selected)Alt+Shift+M: Extract selection to methodAlt+Shift+L: Extract local variable (create and assign a variable from a selected expression)Alt+Shift+I: Inline selected local variables, methods, or constants if possible
11. Run and Debug
Ctrl+F11: Save and launch application (Run)F11: DebugF5: Step Into functionF6: Next step (line by line)F7: Step outF8: Resume / Skip to next Breakpoint
12. Others
Ctrl+F7/Ctrl+Shift+F7: Switch forward / backward between views (panels)Ctrl+F8/Ctrl+Shift+F8: Switch forward / backward between perspectivesCtrl+P: PrintF1: Open Eclipse HelpShift+F10: Show context menu (right click)Ctrl+3: Quick Access — focus the Quick Access box to execute any Eclipse commandCtrl+Shift+O: Organize importsAlt+Shift+SthenR: Generate getter and setter methodsCtrl+Space: Type assist (Content Assist)Alt+Shift+Z: Enclose block in try-catchShift+F2: Show Javadoc for current element
Last updated: (replace with actual date when you update this page)
If you want this as a printable one-page cheat sheet, consider generating a PDF from this page or linking to a downloadable image. If you customize or rebind keys in Eclipse, set a note or link to your key-bindings guide under the editor preferences.
No comments:
Post a Comment