IntelliJ IDEA 12 Keep Blank Lines
Asked Answered
C

1

10

I have this code:

private int a;

private int b;

private int c;

But when I reformat it with IntelliJ, it changes to this:

private int a;
private int b;
private int c;

How would I allow it to keep the blank lines?

But this code:

private boolean a;
private String s;

Should stay as it is.

Cammie answered 23/1, 2013 at 10:13 Comment(1)
You can use Eclipse Code Formatter.Bind
T
11

The problem is caused by the Rearranger bug, at the moment it doesn't honor the maximum blank lines setting. I've created the issue that you can follow for progress.

Topmast answered 23/1, 2013 at 10:51 Comment(10)
I should've been more specific in the original post, that option will apply blank lines around all fields. I do not want this. I would like it so if there already is a blank line between fields leave it there.Cammie
In this case change the first option instead (Keep Maximum Blank Lines, In declarations), use some larger value so that IDEA doesn't remove blank lines, for example values 1 or 2 will leave the provided sample code untouched.Topmast
Please zip and share a sample project with the embedded code style that will reproduce this problem with reformat in IDEA 12.0.2.Topmast
up.ht/SHFd2F When reformatting that code the line breaks between the field groups get removed. I do not want that and I don't want to break the field groups up either.Cammie
Not reproducible for me with the default code style settings, rename IDEA folders to start with all the defaults and see if the issue remains. It can be caused by some third-party plug-in or corrupted configuration.Topmast
It works with default configuration and system settings o.O I'll change a few things and keep testing to find what's doing it :pCammie
I found out it's something to do with my custom keymap :S When I use default it works otherwise it doesn't :( It seems to be the keyboard shortcut to "Reformat Code". When I use the shortcut it removes all blank lines but if I right click the file it works :SCammie
It seems to be the new Rearrange Code. Here is how I am rearranging the code : puu.sh/1Snd3Cammie
Updated the answer, it's a bug.Topmast
@Topmast Is there a workaround for this bug? My work install exhibits the problem, while my home install do not. I tried importing my home settings, but it didn't change anything. Both have the latest version (12.1.2).Blueness

© 2022 - 2024 — McMap. All rights reserved.