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 ctrl + d.
Yank ctrl+y
Press ctrl + y repeatedly to delete the lines.
NOTE:
Similar to theyank
command in (vim)[https://www.vim.org/], the text you removed is available in your paste-buffer. Meaning that pasting will reproduce the lines you just yanked out.
Moving lines with and without constraints ctrl+shift+up/down vs. alt+shift+up/down
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 alt + 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 ctrl + shift and press ↑ or ↓ to move the entire method.
Start new line shift+enter
In Chapter4.java
, jump to 20:20 (using ctrl + g). 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 ctrl+shift+j
We want to write the return statement of _4_thundercats()
on just one line.
Don’t use a sequence of end + delete combinations.
Instead, first select all the thundercats’ names (the strings), then press ctrl + shift + j (for Join lines).
Hint:
use ctrl + w right after the{
character.
You might have to repeat the ctrl + shift + j combination, because IntelliJ’s auto-formatting tends to kick in sometimes.