Intellij IDEA plus sign when String wrap

后端 未结 4 1072
半阙折子戏
半阙折子戏 2020-12-23 19:08

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:

<         


        
相关标签:
4条回答
  • 2020-12-23 19:19

    Settings | Code Style | Wrapping and Braces, under Binary Expressions group enable Operation sign on next line:

    Operation sign on next line

    0 讨论(0)
  • 2020-12-23 19:19

    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
    }
    
    0 讨论(0)
  • 2020-12-23 19:31

    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)

    0 讨论(0)
  • 2020-12-23 19:31

    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"

    0 讨论(0)
提交回复
热议问题