intellij-idea Selection


Selection with increasing scope

This comes handy when you want to select a block to extract a variable / method etc, no need to do a precise bracket matching, just put the caret somewhere in the statement and keep doing this

Windows: Ctrl + W

OS X / macOS: Cmd + W

Selection with decreasing scope

Windows: Ctrl + Shift + W

OS X / macOS: Cmd + Shift + W

This feature is also very useful when editing / playing with json documents in your IDE.

Vertical selection

Press and hold

Windows: Alt

OS X / macOS: Opt

and select normally using mouse / trackpad (the way you select a word in a row etc)

This is how it should look like

Multiple carets

Press and hold

Windows: Alt + Shift

OS X / macOS: Opt + Shift

and click where all you want to put a caret. You can choose to put multiple carets in a single line or across lines at different positions.

Now you can perform all operations that you would have been able to perform on a single selected word (hold Ctrl (windows) or option (mac OS) and use Left or Right keys to jump across words) and all those will affect all caret positions.

You can even cut / paste multiple selections from one place to another.

Having multiple carets is very usefult when you want to change the structure of text across many lines / many positions in same line.

Selecting duplicate occurences

Select some text and press

Windows: Alt + J

OS X / macOS: ctrl + G

to select the next occurance of the same text.

You get one caret at each of the selected occurrence that could be used to change each occurrence simultaneously.

E.g., I've tried to put an example in this gif, hope it helps