How to have the formatter wrap code with IntelliJ?
Do you mean that the formatter does not break long lines? Then please check:
Settings / Project Settings / Code Style / Wrapping
Update: In later versions of IntelliJ, the option can be found under:
Settings / Editor / Code Style
There select Wrap when typing reaches right margin
.
IntelliJ IDEA 14, 15, 2016 & 2017
Format existing code
Ensure right margin is not exceeded
File > Settings > Editor > Code Style > Java > Wrapping and Braces > Ensure right margin is not exceeded
Reformat code
Code > Reformat code...
or press Ctrl + Alt + L
If you have something like this:
thisLineIsVeryLongAndWillBeChanged(); // comment
it will be converted to
thisLineIsVeryLongAndWillBeChanged(); // comment
instead of
// comment thisLineIsVeryLongAndWillBeChanged();
This is why I select pieces of code before reformatting if the code looks like in the previous example.
Wrap when typing reaches right margin
IntelliJ IDEA 14: File > Settings > Editor > Code Style > Wrap when typing reaches right margin
IntelliJ IDEA 15, 2016 & 2017: File > Settings > Editor > Code Style > Wrap on typing