How can I set a maximum length for Android Studio\'s code editor, or may be set a word wrap?
In my Android Studio, no matter how long a statement I type on a single
The existing answers already answer the question in straight forward way. As a different approach you could set the style guide to kotlin style guide code style. Then if you do alt + ctrl + l as you did, you'll see auto wrap as you expected.
Just open the settings, search for kotlin and look for kotlin under code style.
On the top right hand side of the settings window you'll see Set from..., click on it.
Then on predifined style > kotlin style guide
If you'd like to follow the kotlin formatting style this could reduce more effort. For more information: https://developer.android.com/kotlin/style-guide
In settings/code style/kotlin/wrapping and braces replace the "do not wrap" values with "wrap if long"
In Android Studio: File->Setting-> Editor->code Style->java->Wrapping and braces(tab:right side)->keep when reformatting->Line break(make unchecked)
If you need not a soft wrap,
but actually, brake one long line onto several lines you need:
Go to Preferences -> Editor -> Code style -> Java/Kotlin -> Wrapping and braces (tab) -> Check "Ensure that right margin is not exceeded"
Now try to reformat your code:
press
OPTION (ALT) + CMD + L on your Mac
(or CTRL + ALT + L on PC)
Edit 13.02.19
As noted in comments this option seems not available in settings for Kotlin.
However, there is a workaround to manually add it.
Here is what it takes to make it work:
Export the settings scheme.
Open saved xml file.
<codeStyleSettings language="kotlin"> tag (or create)Add the WRAP_LONG_LINES setting manually:
<codeStyleSettings language="kotlin">
...
<option name="WRAP_LONG_LINES" value="true" />
</codeStyleSettings>
My Environment:
My operate:
Android Studio 3.5:
Mac -
Android Studio > Preferences > Editor > CodeStyle > HardWrap at: ____