Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 3.36 KB

chapter3.md

File metadata and controls

56 lines (40 loc) · 3.36 KB

Chapter 3 - Selection

Back to outline

Move + Select MacMac, shift + arrows

Open Chapter3.java, then move your cursor to the beginning of the line containing "jumps over", hold down Mac, shift and press the right arrow key to select that sentence. Now cut and paste it behind the first line.

Expand Selection Mac +

Press Mac + o and open Fugly.java. Move your cursor to line 23, column 28 by pressing Mac + l and typing 23:28. From that position press Mac + , press this key combination again a few times, and see what happens.

Now try using Mac + 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?

Using Selection to help Navigation (e.g. Fluent API)

Because Mac + expands a selection, and because the arrow keys decide where our cursor is going to be: Mac at the beginning or Mac 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 Mac + until you have a selection containing a "method call", e.g. fugly(), then press Mac to put your cursor at the end, and press Mac (Macenter). Rinse and repeat.

Wrapping (IntelliJ feature)

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 Mac + ,, 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 Mac + shift + a, and then type Smart Keys Braces. Fix the wrapStuff method by selecting "efffff" with Mac + 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).


Next Chapter

Back to outline