Intellij – 如何强制在操作符处分割,而不是在最大尺寸处分割

huangapple go评论49阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年7月17日 16:53:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76702844.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定