Skip to the content.

Chapter 4 - Line Editing

Back to outline

Authors pro-tip:
Listen to this song while working through the exercises

Duplicate line Windowsctrl+d

Open Chapter4.java, move your cursor to line 6 (try and use a shortcut for this), and press Windowsctrl + d.

Yank Windowsctrl+y

Press Windowsctrl + y repeatedly to delete the lines.

NOTE:
Similar to the yank 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 Windowsctrl+shift+up/down vs. Windowsalt+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 Windowsalt + shift and press or Windows 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 Windows or to move the entire method.

Start new line Windowsshift+enter

In Chapter4.java, jump to 20:20 (using Windowsctrl + g). From this position we want to start implementing the body of the method. Typically, one would do this by pressing Windowsend, and then Windowsenter. But you can do this in one go by pressing Windowsshift + enter, so let’s do just that.

This will come in handy later.

Join lines Windowsctrl+shift+j

We want to write the return statement of _4_thundercats() on just one line. Don’t use a sequence of Windowsend + delete combinations. Instead, first select all the thundercats’ names (the strings), then press Windowsctrl + shift + j (for Join lines).

Hint:
use Windowsctrl + w right after the { character.

You might have to repeat the Windowsctrl + shift + j combination, because IntelliJ’s auto-formatting tends to kick in sometimes.


Next Chapter

Back to outline