Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 969
Craig Avatar asked Jun 17 '14 10:06

Craig


People also ask

How do I select a method in IntelliJ?

Navigate with the Select In popup If the class is opened in the editor, press Alt+F1 to open the Select In popup. In the popup, select Project View and press Enter . IntelliJ IDEA locates your target in the Project tool window.


2 Answers

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

like image 76
g-t Avatar answered Sep 17 '22 19:09

g-t


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 + { 
like image 33
zeeshan Avatar answered Sep 16 '22 19:09

zeeshan