Open Chapter3.java
, then move your cursor to the beginning of the line containing "jumps over"
, hold
down ⌘, shift and press the right arrow key → to select that sentence.
Now cut and paste it behind the first line.
Press ⌘ + o and open Fugly.java
.
Move your cursor to line 23
, column 28
by pressing ⌘ + l and typing 23:28
.
From that position press ⌥ + ↑, press this key combination again a few times, and see what happens.
Now try using ⌥ + shift + ↑ to incrementally reduce the size of your selection. Play around with both the
Expand selection
and Reduce selection
key combinations until you feel comfortable with them.
What happens if you keep on pressing that combination?
Because ⌥ + ↑ expands a selection, and because the arrow keys decide where our cursor is going to be: ← at the beginning or → at the end of the selection.
We can use a little trick to format our Fluent API.
Format the one-liner so that it looks like the method below. You can do this by pressing ⌥ + ↑ until you have a selection
containing a "method call", e.g. fugly()
, then press → to put your cursor at the end, and press ⏎
(enter).
Rinse and repeat.
IntelliJ has a neat feature that wraps your selection with braces, curly braces, single or double quotes, ...
You can enable this feature under Settings
by pressing ⌘ + ,, then go to Editor > General > Smart Keys
,package be.swsb.productivity.chapter3;
public class Chapter3 {
public String selectStuff() {
return "The quick brown fox " +
"jumps over " +
"the LazyDawg";
}
}
and enable Surround selection on typing quote or brace
.
An alternative is by pressing ⌘ + shift + a, and then type Smart Keys Braces
.
Fix the wrapStuff
method by selecting "efffff"
with ⌥ + ↑s, and then type a "
.
Then apply the same pattern to yewwww
but instead of a "
, type a (
.Then apply the same pattern to the entire method body but type a {
.
This feature really shines in combination with multi-cursor (which we'll discuss in detail later on).