Thursday, June 11, 2015

Essential Eclipse IDE Keyboard Shortcuts — Windows & Linux (Cheat Sheet)

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

  • Shortcuts below are given for Windows and Linux. On macOS, replace Ctrl with Cmd where 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 Wizard
  • Ctrl+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 properties
  • Ctrl+S : Save current file
  • Ctrl+Shift+S : Save all files
  • Ctrl+W : Close current file
  • Ctrl+Shift+W : Close all files
  • Ctrl+P : Print the file
  • F5 : 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 Window
  • Ctrl+PageDown / Ctrl+PageUp : Switch to next editor / previous editor
  • Ctrl+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 Ctrl
  • Alt+← / Alt+→ : Go to previous / next editor window
  • Alt+- : Open editor window option menu
  • Ctrl+F10 : Show view menu (features available on left vertical bar: breakpoints, bookmarks, line numbers, …)
  • Ctrl+F10, then n : Show or hide line numbers
  • Ctrl+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 line
  • Ctrl+Home / Ctrl+End : Jump to beginning / end of source
  • Ctrl+← / Ctrl+→ : Jump one word left / one word right
  • Ctrl+Shift+↓ / Ctrl+Shift+↑ : Jump to previous / next method
  • Ctrl+L : Jump to line number. (To hide/show line numbers: Ctrl+F10 then select 'Show Line Numbers')
  • Ctrl+Q : Jump to last location edited
  • Ctrl+. / Ctrl+, : Jump to next / previous compiler syntax warning or error
  • Ctrl+Shift+P : With a bracket selected: jump to the matching bracket
  • Ctrl+[+] / Ctrl+- on numeric keypad : Collapse / expand current method or class
  • Ctrl+[/] / Ctrl+* on numeric keypad : Collapse / expand all methods or classes
  • Ctrl+↓ / Ctrl+↑ : Scroll editor without changing cursor position
  • Alt+PageUp / Alt+PageDown : Next sub-tab / previous sub-tab
  • Ctrl+F7 : Next View
  • Ctrl+Shift+F7 : Previous View
  • Ctrl+F8 : Next Perspective
  • Ctrl+Shift+F8 : Previous Perspective
  • Ctrl+. : Go to the next problem / error
  • Ctrl+, : Go to the previous problem / error

4. Select Text

  • Shift+→ / Shift+← : Expand selection by one character right / left
  • Ctrl+Shift+→ / Ctrl+Shift+← : Expand selection to next / previous word
  • Shift+↓ / Shift+↑ : Expand selection by one line down / up
  • Shift+End / Shift+Home : Expand selection to end / beginning of line
  • Ctrl+A : Select all
  • Alt+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 element
  • Alt+Shift+↓ : Reduce previously expanded selection by one step

5. Edit Text

  • Ctrl+C / Ctrl+X / Ctrl+V : Copy, Cut and Paste
  • Ctrl+Z : Undo last action
  • Ctrl+Y : Redo last (undone) action
  • Ctrl+D : Delete line
  • Alt+↑ / Alt+↓ : Move current line or selection up or down
  • Ctrl+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 word
  • Ctrl+Backspace : Delete previous word
  • Shift+Enter : Enter line below current line
  • Shift+Ctrl+Enter : Enter line above current line
  • Insert : Toggle between insert and overwrite mode
  • Shift+Ctrl+Y : Change selection to all lower case
  • Shift+Ctrl+X : Change selection to all upper case

6. Search and Replace

  • Ctrl+F : Open find and replace dialog
  • Ctrl+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 pressing Ctrl+J)
  • Ctrl+Shift+O : Open a resource search dialog to find any class
  • Ctrl+J : Incremental search without popup dialog; press Ctrl+J to find the next match
  • Ctrl+Shift+G : In the Java editor, search for references in the workspace
  • Ctrl+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 text
  • Ctrl+I : Correct indentation of selected text or current line
  • Ctrl+Shift+F : Autoformat all code in editor using code formatter
  • Ctrl+/ : Comment / uncomment line or selection (adds //)
  • Ctrl+Shift+/ : Add block comment around selection (adds /* ... */)
  • Ctrl+Shift+\ : Remove block comment
  • Alt+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 Assist
  • Alt+/ : 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 / structure
  • F2 : Open class, method, or variable information (tooltip text)
  • F3 : Open Declaration — jump to declaration of selected class, method, or parameter
  • F4 : Open Type Hierarchy window for selected item
  • Ctrl+T : Show / open Quick Type Hierarchy for selected item
  • Ctrl+Shift+T : Open Type in Hierarchy
  • Ctrl+Alt+H : Open Call Hierarchy
  • Ctrl+U : Find occurrences of expression in current file
  • Ctrl+move over method : Open Declaration or Implementation (hover and Ctrl+click behavior)

10. Refactoring

  • Alt+Shift+R : Rename selected element and all references
  • Alt+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 method
  • Alt+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 : Debug
  • F5 : Step Into function
  • F6 : Next step (line by line)
  • F7 : Step out
  • F8 : 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 perspectives
  • Ctrl+P : Print
  • F1 : Open Eclipse Help
  • Shift+F10 : Show context menu (right click)
  • Ctrl+3 : Quick Access — focus the Quick Access box to execute any Eclipse command
  • Ctrl+Shift+O : Organize imports
  • Alt+Shift+S then R : Generate getter and setter methods
  • Ctrl+Space : Type assist (Content Assist)
  • Alt+Shift+Z : Enclose block in try-catch
  • Shift+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: