Using Intellij to select block between parentheses () or brackets [] or curly brackets {} either with keyboard or mouse

One of which is selecting blocks between {}, (), or [] or jumping between the opening/closing of a block.

Let's assume you have cursor on itemA.

Ctrl+W -> selected:

itemA

Ctrl+W -> selected:

method2(itemA)

Ctrl+W -> selected:

item1, method2(itemA), item3,
                item4, item5

Ctrl+W -> selected:

method(item1, method2(itemA), item3,
                item4, item5)

And so on. After that it would select whole method, class etc. Honestly this is the shortcut which I use most frequently. Unfortunately I sometimes try to use that in other applications - each web browser closes tab by pressing Ctrl+W :)

Another thing is:

  • Ctrl + {
  • Ctrl + }

It jumps to opening / closing bracket


In Mac, go to start of a block and do:

Command + Shift + Alt + }

or go to end of a block and do:

Command + Shift + Alt + {

In Windows do it as:

Ctrl + Shift + }

and

Ctrl + Shift + {

I've been using Ctrl+W, but this is very annoying as it first selects a word, then an enclosing statement, then another enclosing statement and so on. You have to press Ctrl+W just too much times.

The best way I've figured for any block selection is:

  1. Press Ctrl+{ - this will take you to the beginning of the block
  2. Press Ctrl+Shift+} - this will select the whole block from the beginning to the end.

This way you're able to select a block of any size with any amount of nested blocks with few actions.