Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force code formatter in IntelliJ to join lines

I'm trying to force IntelliJ to reformat the code the way Eclipse does it. When I set a line width to e.g. 120 chars I would like IDE to join line that were broken up to multiple lines (e.g. because the line width was set to 80 chars).

I want to go from here:

int a = 1
    + 2;

To here:

int a = 1 + 2

Is it possible in IntelliJ? I'm looking for the appropriate setting in the formatter but cannot find it. Could someone tell me where I can find it?

like image 200
Krzysztof Krasoń Avatar asked Dec 08 '09 14:12

Krzysztof Krasoń


2 Answers

This works for me in intellij 8 if i go to:

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

Then CTRL-ALT-L to reformat the code

like image 105
andy boot Avatar answered Oct 05 '22 07:10

andy boot


Menu -> Edit -> Join Lines (Ctrl+Shift+J)

like image 34
Pavel Burik Avatar answered Oct 05 '22 06:10

Pavel Burik