Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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();

}
like image 295
Jonathan Beaudoin Avatar asked Jan 22 '16 14:01

Jonathan Beaudoin


People also ask

Should be on a new line IntelliJ?

There are shortcuts for this in IntelliJ IDEA! Simply hit Shift+Enter to start a new line below the current line or Ctrl+Alt+Enter (⌥⌘Enter on Mac) to start a new line above the current line.

How do I ignore a class in IntelliJ?

So the easiest way to exclude your test is to create a third source folder, call it /ignore, and not mark it as a source folder in IntelliJ. You can then drop any file you don't want to include in your compilation there temporarily, and drag it back to its original folder when you want to continue working on it.


1 Answers

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

like image 127
jheimbouch Avatar answered Oct 02 '22 01:10

jheimbouch