Manius
Manius

Reputation: 3644

Add indentation to blank lines in Java code (Eclipse IDE)

Using Eclipse is it possible (via formatter or other setting) to automatically pre-indent blank lines in Java code with the appropriate number of tabs (or whitespace)?

(Not interested in arguing about others opinion that this is a bad idea or "wastes bytes" (hahaha) or any other such nonsense - just want to know if it's possible, thanks.)

Edit: Actually this may be a problem that can be fixed with templates (I've had no success so far), but when I generate a new class I get methods like this:

    @Override
    public void setData(Object data) {
//No indentation on first line :(
    }

The formatter, even with "Indent empty lines" checked, definitely doesn't add tabs there either. Maybe this is a bug?

Upvotes: 5

Views: 3150

Answers (1)

Dr G
Dr G

Reputation: 4017

Yep, you can do that. Go to Preferences/Java/Code Style/Formatter and edit your active profile. Then on the Indentation tab tick empty lines.

enter image description here

Upvotes: 10

Related Questions