Chapter 4 - Line Editing
Authors pro-tip:
Listen to this song while working through the exercises
Duplicate line ctrl+d
Open Chapter4.java
, move your cursor to line 6 (try and use a shortcut for this), and press ⌘ + d.
Yank ⌘ + backspace
Press ⌘ + backspace repeatedly to delete the lines.
Moving lines with and without constraints ⌥ + shift + ↑/↓ vs. shift + ⌘ + ↑/↓
While in Chapter4.java
, the System.out.println
function calls are switched around.
Place your cursor on one of the System.out.println
lines, hold down ⌥ + shift and press ↑ or
↓ to move that line.
Do the same for the other line.
You will see the methods aren’t in the desired order yet, so place your cursor on _2_snarf
’s method signature.
This time hold down shift + ⌘ and press ↑ or ↓ to move the entire method.
Start new line shift + enter
In Chapter4.java
, jump to 20:20 (using ⌘ + l). From this position we want to start implementing the body of the
method. Typically, one would do this by pressing end, and then enter. But you can do this in one go by
pressing shift + enter, so let’s do just that.
This will come in handy later.
Join lines ⌃ + shift + j
We want to write the return statement of _4_thundercats()
on just one line.
Don’t use a sequence of ⌘ + →, delete combinations.
Instead, first select all the thundercats’ names (the strings), then press ⌃ + shift + j (for Join lines).
HINT:
use ⌥ + ↑ right after the{
character.
You might have to repeat the ⌃ + shift + j combination, because IntelliJ’s auto-formatting tends to kick in sometimes.