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.

icktoofay
  • 126,289
  • 21
  • 250
  • 231
Ramus
  • 250
  • 1
  • 2
  • 10
  • You can use [Eclipse Code Formatter](http://plugins.jetbrains.net/plugin/?webide&pluginId=6546). – madhead Jan 23 '13 at 10:19

1 Answers1

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.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 3
    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. – Ramus Jan 23 '13 at 15:17
  • 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. – CrazyCoder Jan 23 '13 at 15:40
  • Please zip and share a sample project with the embedded code style that will reproduce this problem with reformat in IDEA 12.0.2. – CrazyCoder Jan 24 '13 at 09:29
  • 2
    http://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. – Ramus Jan 24 '13 at 18:26
  • Not reproducible for me with the default code style settings, rename [IDEA folders](http://devnet.jetbrains.net/docs/DOC-181) 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. – CrazyCoder Jan 24 '13 at 20:02
  • 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 :p – Ramus Jan 25 '13 at 10:05
  • 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 :S – Ramus Jan 25 '13 at 10:32
  • It seems to be the new Rearrange Code. Here is how I am rearranging the code : http://puu.sh/1Snd3 – Ramus Jan 25 '13 at 10:43
  • Updated the answer, it's a bug. – CrazyCoder Jan 25 '13 at 11:57
  • 1
    @CrazyCoder 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). – nicopico May 06 '13 at 08:53