Reputation: 1944
How to setup IntelliJ IDEA to prevent the splitting of an anonymous class, declared on one line, into several lines during auto-reformating (CTRL+ALT+L)?
For example, to prevent the splitting of
x = foo(new Boo() {});
into two lines:
x = foo(new Boo() {
});
Upvotes: 5
Views: 6231
Reputation: 97152
Stumbled on this old question when searching for the same. The option Simple classes in one line has since been added to IntelliJ.
It can be found in the settings under Editor > Code Style > Java > Wrapping and Braces, in the Keep when reformatting field set.
Upvotes: 5
Reputation: 1024
"File" [menu]/"Settings"/"Code Style"/"Alignment and Braces":
==> "Keep when Reformatting" Field Set:
Check: "Simple methods in one line"
Check: "Simple blocks in one line"
Upvotes: 6