Skip to content
Advertisement

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

I’ve started working with IntelliJ and I really like it, but there are a few features which I miss compared with Eclipse. One of which is selecting blocks between {}, (), or [] or jumping between the opening/closing of a block. For example, in eclipse if you double click just after an opening parentheses it will select everything up to the matching closing parentheses as in:

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

Where if you double clicked after the opening parentheses method(|, then it would select everything up to the closing parentheses, right after item5. I have discovered that IntelliJ will select method bodies when you double click, but not regions inside of parentheses and not for class bodies.

Also, in eclipse, you can jump between the end and beginning of a block by pressing Ctrl+Shift+P just after the opening/closing of the block. In IntelliJ (using eclipse key mapping), Ctrl+Shift+P simply selects everything up to the method’s closing curly brace ‘}’. I’ve discovered that Ctrl+Shift+} works the way that I expect but only for curly braces {} and it also selects everything between the block be it a method or class rather than just moving the cursor.

I can tell that IntelliJ is fairly sophisticated and customizable, but I can’t figure out how to duplicate this feature from Eclipse. Any assistance would be appreciated in getting this functionality to work.

Thanks in advance! Craig

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement