英文:
Intellij - how to force split on operator rather than on max size
问题
如何告诉IntelliJ像Eclipse一样拆分行:
private static final boolean VERY_VERBOSE = !(System.getProperty("veryverbose") == null
|| System.getProperty("veryverbose").equalsIgnoreCase("false"));
而不是像这样:
private static final boolean VERY_VERBOSE = !(System.getProperty("veryverbose") == null || System.getProperty(
"veryverbose").equalsIgnoreCase("false"));
这意味着如果存在运算符,首选在运算符处拆分而不是在达到最大大小时截断行。
备注:
• 我将硬限制设置为120(我更喜欢保持这个设置)
• 我导入了Eclipse的首选项到IntelliJ,但IntelliJ仍然表现不正常
• 我使用IntelliJ Ultimate 2023.1.2
英文:
How to tell intellij to split lines like Eclipse does:
private static final boolean VERY_VERBOSE = !(System.getProperty( "veryverbose" ) == null
|| System.getProperty( "veryverbose" ).equalsIgnoreCase( "false" ));
and not like this:
private static final boolean VERY_VERBOSE = !(System.getProperty( "veryverbose" ) == null || System.getProperty(
"veryverbose" ).equalsIgnoreCase( "false" ));
That translates to if there is an operator prefer to split on it rather than truncate the line at maximum size
Notes:
• I have hard-limit set to 120 (And I prefer to keep it like that)
• I imported the eclipse preferences to Intellij but IJ still misbehave
I Use intelliJ ultimate 2023.1.2
答案1
得分: 1
尝试在“设置/首选项(在 macOS 上)| 编辑器 | 代码样式 | Java | 换行和大括号”下启用以下选项:
二进制表达式
=>如果很长则换行
二进制表达式 | 下一行显示操作符
=>启用
英文:
Try enabling the following options under Settings/Preferences (on macOS) | Editor | Code Style | Java | Wrapping and Braces
:
Binary expressions
=>Wrap if long
Binary expressions | Operation sign on next line
=>Enable
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论