Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set IDEA better align parameters passed to some method?

I cannot make IDEA perfectly align parameters passed to some method when I break them into new line by Enter key.

Here is visually what I need. I have a method like this.

When I break parameters into new row each, it looks like this.

Even trying to align them with Tab key does not help.

You see how ugly this is, not to say it's not easy to reach such code. And all I want is too look like this:
(Note: this one I set via Space key).

I must have been doing something wrong as I can bet this can be set in IDEA. But where?

like image 647
sandalone Avatar asked Jul 27 '13 16:07

sandalone


2 Answers

Bring up Settings panel :

Code Style > Java > Wrapping and Braces (tab)

Enable Align when multiline option in Method declaration parameters and Method call arguments

like image 124
Rangi Lin Avatar answered Oct 13 '22 11:10

Rangi Lin


Apart from the way suggested by @Rangi Lin, also make sure that your

Code Style > Java > Keep When Reformating > Line Breaks

in your settings is also checked. Otherwise reformatting your code could realign your method params into a single line.

like image 40
Abdullah Khan Avatar answered Oct 13 '22 12:10

Abdullah Khan