Skip to the content.

Chapter 3 - Selection

Back to outline

Move + Select Windowsctrl+shift+arrows

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

Expand Selection Windowsctrl+w

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

Now try using Windowsctrl + shift + w 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 Windowsctrl + w expands a selection, and because the arrow keys decide where our cursor is going to be: Windows at the beginning or Windows 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 Windowsctrl + w until you have a selection containing a “method call”, e.g. fugly(), then press to put your cursor at the end, and press Windows (enter).

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 Windows + >,, then go to Editor > General > Smart Keys, and enable Surround selection on typing quote or brace.

An alternative is by pressing Windowsctrl + shift + a, and then type Smart Keys Braces. Fix the wrapStuff method by selecting "efffff" with Windowsctrl + w, 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