Cheetah
Cheetah

Reputation: 14379

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?

Upvotes: 14

Views: 6783

Answers (2)

Stephan Dhaene
Stephan Dhaene

Reputation: 65

Alternatively, if you have editorconfig setup, you can add the following property to your .editorconfig file:

enter image description here

Upvotes: 1

Dave Newton
Dave Newton

Reputation: 160170

  • 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

Upvotes: 24

Related Questions