简体   繁体   中英

Eclipse Formatter: Break at Greater-Than Sign Rather Than at Dot

I have this line showing the problem:

Which setting in the Eclipse Java formatter do I have to change so the line will break like

return this.data.getNumberOfGenerationsWithoutSignificantImprovementPassed()
            > MAX_NUMBER_OF_GENERATIONS_WITHOUT_SIGNIFICANT_IMPROVEMENT;

or like

return this.data.getNumberOfGenerationsWithoutSignificantImprovementPassed() >
            MAX_NUMBER_OF_GENERATIONS_WITHOUT_SIGNIFICANT_IMPROVEMENT;

? If both is possible, I prefer the former.

On Mac, go to Eclipse -> preferences. On Windows, I believe it is Windows -> preferences... but don't quote me on that!

  • Expand Java -> Code Style -> Formatter
  • To the right of the "Active profile" bar, choose edit.
  • A new window will open- choose the "Line Wrapping" tab.
  • Scroll down to "Expressions" and choose conditionals. Pick your favorite!

Bonus points: This is where you can set all sorts of different styles, if you have not before, like number of spaces per tab character. Once you get everything set up just right, name your profile and export it. I use the same theme on 3 different computers and the consistency is nice!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM