代码之家  ›  专栏  ›  技术社区  ›  Krzysztof Krasoń

强制IntelliJ中的代码格式化程序连接行

  •  7
  • Krzysztof Krasoń  · 技术社区  · 16 年前

    当我将线宽设置为例如120个字符时,我希望IDE将拆分为多行的行连接起来(例如,因为线宽设置为80个字符)。

    int a = 1
        + 2;
    

    int a = 1 + 2
    

    在IntelliJ中可能吗?我正在格式化程序中寻找适当的设置,但找不到。有人能告诉我在哪里能找到它吗?

    4 回复  |  直到 16 年前
        1
  •  7
  •   David C Rodrigo Deodoro    9 年前

    在intellij 8中,如果我去:

    File -> Settings -> Code Style -> Wrapping -> Binary operations -> set to: 'Wrap if long' or 'Do not wrap'
    

    然后 - - L 重新格式化代码

        2
  •  4
  •   ROMANIA_engineer Alexey    11 年前

    菜单->编辑->连接线( Ctrl键 + J

        3
  •  3
  •   James    10 年前

    如果您的代码已经包含不适当的换行符,并且您希望格式化程序在重新格式化期间删除这些换行符,

    File -> Settings -> Code Style -> Wrapping and Braces -> 
    Keep When Formatting -> Line Breaks -> Untick
    

        4
  •  1
  •   nicolimo86    8 年前

    对于Intellij 2016.2.x,我必须在设置中取消选择此选项: enter image description here

    然后返回代码并按 - 中高音 - L