开发者

IntelliJ force code formatter to join lines based on wrap settings

How can i reformat file(s) in IntelliJ and join all lines that are split.

I know that I can do that individually by selecting lines and "join lines" with CTRL + SHIFT + J

Since we changed our code formatting wrap policy recently I want to be able to join lines in all files based on the updated wrap setting. (Settings > Code Style > General > Right margin)

The o开发者_JAVA百科nly thing is that IntelliJ seems happy to split lines based on wrap setting, but will silently deny to join lines based on that setting.

Unlike the question Force code formatter in IntelliJ to join lines, I am not satisfied by splitting lines or joining manually (as the accepted answer suggests). I want IntelliJ to join lines automatically.

Bonus question: Which other editors can do this?


Disable the following code style option - Project Settings - Code Style - Wrapping and Braces - Keep when reformatting - Line breaks


IntelliJ IDEA 15

  • File > Settings... > Editor > Code Style > Java > Wrapping and Braces > Keep when reformatting > uncheck Line breaks

    IntelliJ force code formatter to join lines based on wrap settings

    (if you want to have the same setting for another type of file, choose it from Code Style)

  • Go to Code > Reformat Code (Ctrl + Alt + L).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜