Break long strings in Android Studio?

Viewed 124

I have a project in Android Studio, with a Kotlin file that has several long string literals that stretch outside the hard wrap of 120 characters that I set for my project:

val longString = "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" // It goes on...

I like to format these strings so that they don't go past the maximum 120 characters, which ends up looking like this:

val longString = "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" +
    "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" +
    "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc" // ...

Sometimes these strings change, and I end up having to fix the word wrapping again manually which can be pretty tedious.

I would like to know if it is possible to:

  1. Automatically format a single-line string literal as a multi-line concatenated string, and also
  2. Take an already chunked string property and automatically reformat it so that it is concatenated at the word wrap?
0 Answers
Related