Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Eclipse break String literal with + operator in next line?

Tags:

eclipse


(Edited) NOTE: this question is NOT about how Eclipse's code formatter wrap long String literals. It is the behavior of MANUALLY breaking/wrapping String literal


The default behavior when I break a String literal by hitting enter inside the literal, is Eclipse will append " + at the place I hit enter, and start the rest of my line in next line, with " prefixed.

                            // v ENTER HERE
String longString = "abcdefghij|klmno";

String longString = "abcdefghij" +
        "klmno";

However, normal coding style practice suggests line wrap before operator. Is there any way that I can tell Eclipse to break my String like this?

String longString = "abcdefhij"
        + "klmno";
like image 396
Adrian Shum Avatar asked Jul 20 '12 10:07

Adrian Shum


1 Answers

In 4.3 you can control this setting with the Wrap before operator checkbox for Binary expressions.

Formatter settings in Eclipse Luna

like image 126
Lukas Glowania Avatar answered Sep 22 '22 18:09

Lukas Glowania