2

When I am entering a String literal in a Java file in Eclipse, and I want to break the String into multiple lines in the source (not the String's content/value), by default Eclipse wants to put the + at the beginning of the new line instead of at the end of the previous line.

For example, where | represents the text cursor:

String str = "This is a really long line which I would like| to break into several."

When I hit Enter, it now looks like:

String str = "This is a really long line which I would like"
    + " to break into several."

But I want it to look like:

String str = "This is a really long line which I would like" +
    " to break into several."

Where in Eclipse can I set the preference for where this + goes?

Mar
  • 7,765
  • 9
  • 48
  • 82
  • 1
    This should help you http://stackoverflow.com/questions/11289076/change-how-eclipse-formatter-wraps-long-strings – likeToCode Apr 18 '15 at 07:44

1 Answers1

1

You could either try the link that I have mentioned in my comment earlier or try the below settings. In my Eclipse, the settings were different, If you go to the "Preferences > Java > Code Style > Formatter" you have an Active Profile which you can Edit. Please find below the settings.

Preferences > Java > Code Style > Formatter -> Edit -> Line Wrapping Tab -> Expressions -> Binary Expressions -> Line Wrapping Policy -> Wrap where necessary -> (check box) Wrap before operator

likeToCode
  • 852
  • 2
  • 10
  • 20