Intellij IDEA plus sign when String wrap

StringIntellij Idea

String Problem Overview


I'm using Intellij IDEA 10.5 Community. If I have a long String and want to split in in mulitple lines I press ENTER key in the middle of a String and get this:

String str = "ONE LONG" +
             "STRING";

Is it possible to put the + sign in the beginning of the line, like this:

String str = "ONE LONG"
             + "STRING";

String Solutions


Solution 1 - String

Settings (Preferences on macOS) | Editor | Code Style | Java | Wrapping and Braces | Binary expressions | Operation sign on next line:

Operation sign on next line

Solution 2 - String

In IntelliJ 15 this setting is in the preferences under

Editor > Code Style > Java > Wrapping and Braces (tab) > Binary Expressions (group) > Operation sign on next line (check box)

Solution 3 - String

In 2016.3 only this helped me:

while in editor, click on menu : code->generate->tostring->settings->template tab-> copy "String concat (+)", this would allow you to edit a new template.

then in template paste this:

public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
    return "$classname{"
#foreach( $member in $members )
#if ( $i == 0 )
    + " ##
#else
    + ", ##
#end
#if ( $member.objectArray )
#if ($java_version < 5)
$member.name=" + ($member.accessor == null ? null : java.util.Arrays.asList($member.accessor)) +
#else
$member.name=" + java.util.Arrays.toString($member.accessor)
#end
#elseif ( $member.primitiveArray && $java_version >= 5)
$member.name=" + java.util.Arrays.toString($member.accessor) 
#elseif ( $member.string )
$member.name='" + $member.accessor + '\'' 
#else
$member.name=" + $member.accessor
#end
#set ( $i = $i + 1 )
#end
    + '}';
#else
    return "$classname{}";
#end
}

Solution 4 - String

In case someone is using Android Studio:

Android Studio > Settings > Editor > Code Style > Java

Click on tab "Wrapping and Braces" and then find the "Binary expressions" group. There you have the checkbox "Operation sign on next line"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkovicaView Question on Stackoverflow
Solution 1 - StringCrazyCoderView Answer on Stackoverflow
Solution 2 - StringArminView Answer on Stackoverflow
Solution 3 - Stringwaypoint100View Answer on Stackoverflow
Solution 4 - StringgiroxiiiView Answer on Stackoverflow