Intellij IDEA plus sign when String wrap
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";
Settings (Preferences on macOS) | Editor | Code Style | Java | Wrapping and Braces | Binary expressions | Operation sign on next line:
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)
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
}
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"