Reputation: 3644
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
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.
Upvotes: 10