Android Studio: line wrapping string literals

1k Views Asked by At

Android Studio supports a variety of wrapping options in its Code Style preferences... But I seem to be unable to find a way to have Android Studio wrap string literals which exceed the specified maximum line length.

All my other wrapping works fine, but something like this..

                                                   |
Log.l("SOMETAG", "Some rather long log message which exceeds the line length.");
                                                   |

.. will be wrapped like this, whith the literal still exceeding the line length max (here marked by |).

                                                   |
Log.l("SOMETAG",
    "Some rather long log message which exceeds the line length.");
                                                   |

What I would expect is something like this:

                                                   |
Log.l("SOMETAG", "Some rather long log message " +
    "which exceeds the line length.");
                                                   |

Anyone know of a way to achieve string wrapping as described??

Note: To the best of my knowledge all string literals concatenated using the + operand will be merged into single constant values by the Java compiler anyway, so although on the first glance it seems like there might be a difference in terms of the executed code there isn't one.

1

There are 1 best solutions below

0
On

Go to File>> Settings>>Editor>>Java>> check the Ensure right margin is not exceeded box on the right>>