Jonathan Beaudoin
Jonathan Beaudoin

Reputation: 2188

IntelliJ insert blank line before last '}' in class files

I've been trying to find the option of inserting a blank line before the closing '}' of the class and have not found it.

My goal is to format

interface IShooter {

    void incHealth(); // health++

    void decHealth(); // health--

    int getHealth();
}

to this

interface IShooter {

    void incHealth(); // health++

    void decHealth(); // health--

    int getHealth();

}

Upvotes: 8

Views: 2603

Answers (2)

Jake H.
Jake H.

Reputation: 969

This is not possible with stock IntelliJ. If you open up Preferences > Editor > Code Style > Java and then click the Blank Lines Tab. you can see a list of options.

As you can see, there is an option for Maximum Blank Lines Before '}' but unfortunately not for Minimum Blank Lines.

enter image description here

UPDATE:

"Before class end" option was added to "Minimum Blank Lines".

Available since 2018.2 - Youtrack Ticket

enter image description here

Upvotes: 9

AlexAc
AlexAc

Reputation: 73

Settings > Editor > Code Style > Java -> Blank Lines Tab

Before class end: 1

Preview

Upvotes: 5

Related Questions