1

enter image description hereI've started working with Intellij (used Eclipse before), and I can't seem to mimic the eclipse formatting

the Eclipse Code Formatter plugin did most of the work, but there are still some differences.

for example:

Original line:

object.add(new ClassForSomething(param1, param2, paramObj.method()));

with IntelliJ formatting:

object.add(new ClassForSomething(param1, param2, paramObj
          .method()));

with Eclipse formatting:

object.add(new ClassForSomething(param1, param2, 
          paramObj.method()));

where do I find the configuration to adjust my intelliJ formatter to what I used to have on the eclipse?

EDIT 1: I've uploaded my code style --> wrapping and braces configuration

Cœur
  • 37,241
  • 25
  • 195
  • 267
Itay Sela
  • 942
  • 9
  • 26
  • please have a look at [this answer](https://stackoverflow.com/questions/9044472/correct-indentation-in-intellij) – DevDio Aug 23 '17 at 13:18

2 Answers2

3

In Preferences > Editor > Code Style > Java > Wrapping and Braces

  • Method call arguments - Do not wrap
  • Take priority over call chain wrapping - True

Here's a screenshot:

enter image description here

I reproduced the method splitting behaviour you described and then 'fixed' it with the settings I propose here. However, there are so many formatter configurations, some of which impact each other, that it's possible I haven't reproduced exactly what you are seeing. If so, then I'd suggest trying the following:

  • Save your Java Code Style to a project specific version then start changing its configuration one item at a time until you find the right one.
  • Export your Eclipse codestyle (from Eclipse’s Preferences > Java > Code Style > Formatter and export the settings to an XML file via the Export All button) and then import that into IntelliJ (see screenshot below) ... perhaps IntelliJ can work out the correct configuration from the Eclipse formatter.

enter image description here

glytching
  • 44,936
  • 9
  • 114
  • 120
  • sorry, but this does not seem to solve my problem yet. – Itay Sela Aug 24 '17 at 06:19
  • *Scratches head*. It's possible you have some other formatter configuration which conflicts with the ones I suggested. I have updated my answer to offers two other suggestions. Hope that helps. – glytching Aug 24 '17 at 07:25
  • i tried some examples to understand whats not working, and method calls do not get wrapped when alone. It has something to do with the fact the method call is a parameter – Itay Sela Aug 24 '17 at 13:00
1

Check File -> Settings -> Code Style -> Java -> Wrapping and Braces. Make sure "Chained method calls" is set to "Do not wrap" and two squares are unchecked.

AlminaS
  • 95
  • 5