Appendix A. Keyboard Shortcuts

Eclipse contains a huge number of keyboard shortcuts that, when mastered, can speed up your coding considerably. By using them, you avoid moving your hands from the keyboard to use the mouse. Using the mouse too frequently to perform actions can hurt your productivity.

Evidently, the idea is not to memorize the whole list in order to be super-productive. This list should be used as a reference for those moments when you realize that you have to perform a time-consuming task over and over, and you ask yourself, "Is there a faster way of doing this?"

This is not an extensive list. We have selected some of the most useful shortcuts and organized them in topics to make it easier to browse.

File editor shortcuts

In this section, we'll present some shortcuts that can be useful when using file editors. Mastering them can ease tasks such as code editing, navigation, and code generation.

Code edition shortcuts

The following table contains some of the most used shortcuts related to code editing:

Shortcut

Purpose

Ctrl + C

Copy

Ctrl + X

Cut

Ctrl + V

Paste

Ctrl + Z

Undo

Ctrl + Y

Redo

Ctrl + F

Find/replace

Ctrl + D

Deletes the current line

Alt + up arrow

Alt + down arrow

Moves the current line up or down

Ctrl + Shift + Delete

Deletes the current line's content after the caret

Ctrl + Shift + C

Comments/uncomments the currently selected lines by adding "//"

Ctrl + Shift + /

Comments the current selection by adding /* … */

Alt + Shift + J

Generates element comment to the currently selected element

Ctrl + Shift + B

Adds/removes breakpoint in the current line

Tab

Shift + Tab

Increases/decreases the selected lines' indentation

Ctrl + I

Fixes the selected lines' indentation

Ctrl + Shift + up arrow

Expands the current selection to enclosing element (selects whole method if a portion of the method's code is selected, for example)

Ctrl + Shift + left arrow

Ctrl + Shift + right arrow

Expands the current selection to next/previous element

Code generation and code refactoring shortcuts

As we have seen in Chapter 2, Java Development, Eclipse can generate and refactor code for you. It can perform tasks such as creating method snippets, organizing a class' imports, among others. The following table shows some shortcuts for these tasks:

Shortcut

Purpose

Alt + Shift + R

Renames the currently selected method

Alt + Shift + M

Extracts the current selection to a method

Alt + Shift + O

Organizes imports

Alt + Shift + F

Formats the selection

Alt + Shift + S

Opens the Source dialog (allows generating getters/setters, constructors, to String methods, and so on)

Ctrl + 1

Opens the Quick Fix dialog

Code navigation shortcuts

In big projects, navigating through your source code can be a painful task. Big and numerous source files make it hard to find what you want. Having the following shortcuts under your sleeve might be handy:

Shortcut

Purpose

Ctrl + Shift + up arrow

Ctrl + Shift + down arrow

Moves to next/previous element of the source code (parameter, method, and so on)

Ctrl + Shift + P

When a bracket is selected, it goes to matching bracket

Ctrl + L

Goes to a line

Ctrl + Q

Goes back to last edit location

Ctrl + .

Ctrl + ,

Goes to next/previous annotation (warnings, errors, and so on)

Ctrl + Page Up

Ctrl + Page Down

Goes to next/previous editor window

Ctrl + left-click

When a class name is selected, opens its source code (if available in workspace)

Ctrl + Shift + T

Open Type – Allows you to search workspace's classes by name

Ctrl + Shift + R

Open the Resource—Allows you to search workspace's resources by name

Java shortcuts

The following Java-specific shortcuts are also very useful:

Shortcut

Purpose

F2

Opens the currently selected class' JavaDoc in a tooltip box

F3

Goes to the currently selected element definition (class definition if class is selected, variable declaration if variable is selected)

F4

Opens the Type Hierarchy view for the currently selected class

Ctrl + O

Opens the outline tooltip box for the class currently being edited

Ctrl + Alt + H

Opens the Call Hierarchy view for the method currently being edited

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.34.85