Eclipse hotkeys
Posted by Nazar Leush - 24.03.2008, 22:52Tags: Eclipse java tutorial
Using hotkeys in Eclipse significant improves developers' performance. This article is a short tutorial about main Eclipse functions and their hotkeys. This can help beginners to become experienced Eclipse user faster. This list of functions and hotkeys is made according to their usefulness in author's experience.
Show Key Assist
Control-Shift-L
Shows list of all configured in Eclipse hotkeys. If some dialog window is active - shows only enabled in it keys.
Keys Preferences Window
twice Control-Shift-L
If "show key assist" hotkey pressed twice - keys preferences window will be opened. Use this window to customize keys as you want. This article describes default keys for Eclipse v3.3 and v.3.2.
Views management
Maximize/Restore View
Ctrl-M
Each Eclipse view can be maximized. Frequently developer requires more screen area for code editor. In this case it is useful to maximize view pressing Ctrl-M. The same combination is used for restoring previous view size.
Switching Views
Ctrl-F7
Eclipse has special window for switching between between views (code editor, navigator, console etc). This window is showed when combination is pressed down once. After key releasing Eclipse hides window and switches to previous view. If key is pressed twice Eclipse will switch last but one view and so on. While switching window is opened you can use up and down arrow keys for navigating between opened views. Use enter of left mouse click to select view.
Switching Editors
Ctrl-F6
Switching between editors works the same as switching between views. It works in editor view and switches opened in it files. This function is similar to Ctrl-Tab in many other multiwindow applications. If you wish you can set classical combination for this function in keys preferences window.
Quick Switch Editor
Ctrl+E
This function is alternative for editors switch. The difference is this one shows list with filter input.
Last Edit Location
Ctrl-Q
This navigation feature is useful after surfing source code when you want to return back to edit position.
Perspective Switch
Ctrl-F8
Besides views and editors Eclipse has perspectives. Perspective is customized views layout. Different perspectives used for different programming languages, debugging mode, synchronizing with repository mode and so on.
Show View
Alt-Shift-Q, Q
This view shows all available in environment views with filter input. If you closed needed view or want to open some new one - this feature could help you do this quickly.
Code navigation
Find/Replace
Ctrl-F
Search and replace in open in editor file including use of regular expressions.
Find Next/Previous (when search dialog window is closed)
Ctrl-K
Ctrl-Shift-K
You can continue you last search in file using this keys when search window is closed.
Annotations Navigation
Ctrl-,
Ctrl-.
Annotations - are some markings in the code (e.g. compilation errors). Using this keys you can navigate between annotations in the code. Toolbar menu allows you to select which annotations you want to navigate.
History Navigation
Alt-left arrow
Alt-right arrow
Eclipse stores opened files navigation history. This allows to navigate throught recently viewed or edited in editor files.
Open Declaration
F3
Opens source file and places cursor at the declaration of selected in the source code entity. This function is useful for code analyze when you need to know source of called function or source of instantiated class.
Call Hierarchy
Ctrl+Alt+H
Opens view with selected in the code method's call hierarchy. This function allows to see places where selected method is called.
Hierarchy
F4
Shows view with type hierarchy. Can be used for searching selected method overrides in "Lock View and Show Members in Hierarchy" mode.
CTRL-T
Another view of type hierarchy with quick search field.
Open Type
Ctrl-Shift-T
Shows view with quick search input for searhcing type by name in opened workspace. If you know desired type name this feature will be the fastest way to find it.
Open Resource
Ctrl-Shift-R
Shows similar to previous view for searching resources (e.g. xml, html, css files) in workspace.
Find all references in workspace
Ctrl-Shift-G
Shows all packages, classes and members where selected member is referenced.
Search
Ctrl-H
Opens search window. It allows to search different type of data in workspace. Depending on installed plug-ins there can be simple text search, Java search, tasks search and so on. Search options are available - file mask, regular expression etc.
Code management
Quick Fix
Ctrl-1
Place cursor on error marker (red underscore) and press Ctrl-1 to show context menu with fix choices.
Organize imports
Ctrl-Shift-O
This feature automatically organized imports in currently opened source file. It is also available in quick fix menu but this is faster way to execute.
Source menu
Alt-Shift-S
This shortcut opens context menu for automatic code modifications.
Rename
Alt-Shift-R (in editor)
F2 (for classes in Package Explorer)
One of useful Eclipse refactor features is rename. It can be executed directly in the code for member under cursor or in Package Explorer for selected class. Preview window is available.
Format Source
Ctrl-Shift-F
Eclipse has code formatter which can help you format your source code according to specified rules. Formatter settings is can be found in: Window - Pereferences... - Java - Code Style - Formatter - Edit...
Comment/Uncomment
Ctrl-/
Automatic commenting allows you quickly comment or uncomment selected rows of code.
Code indent
Tab
Shift-Tab
This allows to indent to left or to right selected rows of code.
Copy row
Ctrl-Alt-up/down arrow
Copies selected rows and pastes them below or before depending on which key is pressed (up or down).
Move row up/down
Alt-up/down arrow
Moves selected rows down or up depending on which key is pressed (up or down).
Outline
Quick outline
Ctrl-O
Shows quick class outline with member quick search input. This is the fastest way to navigate in big class structure. Eclipse also has Outline View which receives focus on Alt-Shift-Q, O shortcut. This view is more functional but it has no quick search and takes a lot of place on desktop (views are not hidden automatically) so it is less useful when talking about ergonomic.
Folding
Eclipse supports code structure folding. Particularly editor make folding for methods bodies, comments, imports section. Below folding functions is listed.
Expand in cursor position
Ctrl-+
Collapse in cursor position
Ctrl--
Expand All
Ctrl-*
Collapse All
Ctrl-Shift-/
References
This article was written due to small amount of related information in the Internet. Following resources was used:
- http://jroller.com/krismo/entry/eclipse_hotkeys
- http://www.javaworld.com/javaworld/jw-08-2005/jw-0829-eclipse.html
- http://weblogs.goshaky.com/weblogs/lars/resource/eclipse.pdf
Read also: