Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij code indentation for builders

Currently if I write use the following builder class Intellij will indent the following way

SomeClass.create()
    .someMethod()
    .someOtherMethod();

What I would like it to do is indent like this:

SomeClass.create()
         .someMethod()
         .someOtherMethod();

Does anybody know how to set this up?

like image 220
Cheetah Avatar asked Nov 28 '14 17:11

Cheetah


People also ask

How do I fix code indentation in IntelliJ?

While in the editor, select the necessary code fragment and press Ctrl+Alt+I . If you need to adjust indentation settings, in the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. On the appropriate language page, on the Tabs and Indents tab, specify the appropriate indents options and click OK.

How do I indent automatically in IntelliJ?

Automatically detect indentsPress Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. Select the Detect and use existing file indents for editing checkbox. Apply the changes and close the dialog.


1 Answers

  • Code Style => Java => Wrapping and Braces => Chained Method Calls
  • Align when multiline

enter image description here

Produces the following when reformatting source:

enter image description here

like image 50
Dave Newton Avatar answered Oct 19 '22 11:10

Dave Newton