Reputation: 887
I'm trying to create a code style in IntelliJ to keep formatting consistent. I want to ensure the right margin is not exceeded, but when I reformat and IntelliJ tries to enforce that, it often results in some quite strange looking lines.
For example, it often likes to break the line in the middle of a string resulting in something like
public static final String SOME_CONSTANT_STRING = "A long string that is cut" +
+ " off in the middle.";
What I would like instead, is for IntelliJ to only break the line at whitespace so the line would instead look like
public static final String SOME_CONSTANT_STRING =
"A long string that is cut off in the middle";
Is this behavior possible?
Upvotes: 0
Views: 109
Reputation: 48005
From Preferences > Editor > Code Style > Java > Wrapping and Braces
...
Assignment statement > Wrap if long
Assignment statement > Align when multiline
Here's a screenshot showing the configuration:
Here's a screenshot showing the outcome after applying this formatter to the declaration of a very long string constant:
Upvotes: 1