How to set formatting in IntelliJ Idea to collapse closing brackets to one line?

已回答

When there are multiple closing brackets on separate lines next to each other, I like to collapse them into a single line. An example:

static boolean contains(Collection<Collection<Object>> collection, Object object) {
for (var subcol : collection) {
for (var item : subcol) {
if (item.equals(object)) {
return true;
}}}
return false;
}

This is not exactly what I used in a program, but it shows that collapsing three lines into one saves a lot of space. Usually, I collapse only two lines into one, but even there it's significant.

How can I set IntelliJ Idea to format brackets that way automatically? Ideally in a way that brackets of different types could be combined on one line (“)}”) and outermost class-ending brackets (“public class C { … }”) would always be on a separate line.

1

There is no such option as to merger consecutive closing braces into one line. Please feel free to file a request about it.

There is also a related request: https://youtrack.jetbrains.com/issue/IDEA-116528

1

请先登录再写评论。