Java Reference
In-Depth Information
Another handy new feature in
IDEA
5.0 is the ability to easily reorganize your
code by relocating a selected line, a block of code, or an entire method declara-
tion by moving it up and down in relationship to the existing code structure. For
example, moving a method up within the code relocates it between the two pre-
vious methods. To use this feature, select the code you wish to relocate using any
of the traditional means (such as repeated
Ctrl+W
actions) and then execute the
Code | Move statement up
or
Code | Move statement down
action. Alterna-
tively, you can use the much more convenient
Ctrl+Shift+Up
and
Ctrl+Shift+
Down
shortcuts.
2.2.7
Using IDEA's undo and redo mechanism
You'll find the seemingly standard
Undo
operation, along with its twin
Redo
, at
the top of the
Edit
menu and in the main
IDEA
toolbar. Behind its mild-man-
nered facade hides a powerful editing feature. There are the standard keyboard
shortcuts,
Ctrl+Z
(Undo) and
Ctrl+Shift+Z
(Redo), as well as a special bonus
set,
Alt+Backspace
and
Alt+Shift+Backspace
—options you may find more
convenient to press, if somewhat less familiar.
You're probably familiar with the basic operation of the
Undo
and
Redo
com-
mands.
Undo
backs out the last change you made to the document.
Redo
does
just the opposite: It undoes the last
Undo
command. Note, however, that it
doesn't repeat the last operation—it only restores the document back to the state
before the previous undo. Each time you press
Undo
, you back out the previous
change, moving back in time as it were. Pressing
Redo
of course moves you for-
ward until there are no more changes to reapply. You're free to undo or redo as
long as you want, but when you exit the application, you lose your undo history.
IDEA
's
Undo
feature has one important difference from those you may be used
to: It's smart about deciding what sort of activity constitutes an undoable step. It
doesn't just back out the last typed character, it uses your editing activity to deter-
mine the most logical places to break actions into steps. A number of events are
used to signal the end of a logical step, including these:
Pressing
Enter
■
Using the mouse to reposition the cursor
■
Using any of the navigation shortcuts
■
Cutting, pasting, or tabbing
■