如何在 Android Studio 代码编辑器中设置最大行长? [英] How to set max line length in Android Studio code editor?
问题描述
如何为 Android Studio 的代码编辑器设置最大长度,或者设置自动换行?
在我的 Android Studio 中,无论我在一行中输入多长时间的语句,它都不会自动转到下一行,而是会出现一个水平滚动条.
当我使用 Ctrl
+Alt
+L
(
打开保存的 xml 文件.
查找
标签(或创建)
手动添加 WRAP_LONG_LINES 设置:
...<选项名称=WRAP_LONG_LINES"值=真"/></codeStyleSettings>
保存编辑并导回方案.
给你!
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 line, it never automatically goes to the next line, but rather a horizontal scroll bar appears.
When I autoformat using the Ctrl
+Alt
+L
(reference), nothing happens.
My SO or Google search found a lot of material on this for Eclipse, but not for Android Studio.
If you need not a soft wrap,
but actually, brake one long line onto several lines you need:
Go to Preferences(mac) or Settings(windows) -> 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.
Find
<codeStyleSettings language="kotlin">
tag (or create)Add the WRAP_LONG_LINES setting manually:
<codeStyleSettings language="kotlin"> ... <option name="WRAP_LONG_LINES" value="true" /> </codeStyleSettings>
Save edits and and import back the scheme.
Here you go!
这篇关于如何在 Android Studio 代码编辑器中设置最大行长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!