This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
void someMethod() { <blank line> <blank line> doThing1(); <blank line> <blank line> <blank line> <blank line> doThing2(); <blank line> <blank line> } should be formatted to void someMethod() { <blank line> doThing1(); <blank line> doThing2(); <blank line> } but is not.
I'm not sure what the correct behavior should be. See issue #106815.
Maybe there should be an option to tick-mark "remove extra blank lines". A personal comment: I think "format code" eventually should have a "mode", where you can just type your entire Java class in one single line (if you choose to do that); and after press "reformat code", the whole class should be formatted into a "Sun-style" (or "C", or some other style) format: some "sensible" blank lines should be added automatically - ex. before for-loop, before "if", before "return".... The argument would be: This will completely separate the concern of "coding" from the concern of "formatting" if the use chooses to do so. And that is a good coding productivity gain for some. The open source project Jalopy is a good reference of this. In fact, the tool is useful enough that the author was able to spin off a commercial version of it.
personally I prefer to keep blank lines.
Actually it's be ideal for the "blank line" treatment to have two options that the user can turn on and off: 1. Remove extra blank line like what is mentioned here. 2. Add blank lines before special language construct, such as "return ", "if (", "for (", "while ("...., which is again an ideal borrowed from Jalopy. The key thing here is make the options tick-markable to make everybody happy (if there is ever such thing :)
I agree these need to be options. I for one don't want blank lines removed if I have put them there for a reason. For me this is what happens most, not that I have erroneous blanks lines. Maybe if there was a way to have blank lines removed from a selection that would work for me, but certainly I don't want every one from the entire file. With a selection a method could be selected or whatever, and the blanks could be removed from just that area of the file.
This bug was reported against NetBeans IDE 6.0 or an older release, or against a non-maintained module. NetBeans team does not have enough resources to get to this issue, therefore we are closing the issue as a WONTFIX. If you are interested in providing a patch for this bug, please see our NetFIX guidelines for how to proceed. We apologize for any inconvenience. Thank you. The NetBeans Team
(In reply to wqtnetbeans from comment #0) > void someMethod() { > <blank line> > <blank line> > doThing1(); > <blank line> > <blank line> > <blank line> > <blank line> > doThing2(); > <blank line> > <blank line> > } > > should be formatted to > > void someMethod() { > <blank line> > doThing1(); > <blank line> > doThing2(); > <blank line> > } > > but is not. This problem is still VERY annoying, one <blank line> between every line is bad enough but 5-10 extra lines is criminal.