Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to automatically format long argument lists in Java code so each one is on a separate line?

I understand long parameter lists are generally bad, but can I do so without manually navigating before each argument and placing line breaks? I don't need to format every method in such a way, something like an intention for parameter lists would be great.

Bakery(Baker baker, Policy policy, Cookbook cookbook, Schedule schedule) {}

Bakery(
    Baker baker, 
    Policy policy, 
    Cookbook cookbook, 
    Schedule schedule
) {}
like image 953
gvlasov Avatar asked Feb 14 '15 18:02

gvlasov


1 Answers

Under Settings > Editor > Code Style > Java, under the "Wrapping and Braces" tab, select the "Wrap always" option for "Method declaration parameters".

For added perks, you can even tick the "New line after '('" option to get it to appear similar to how you have it laid out in your question.

like image 137
Makoto Avatar answered Sep 18 '22 06:09

Makoto