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.

Bug 106815 - [UI] Do not remove blank lines
Summary: [UI] Do not remove blank lines
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 blocker with 5 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
: 227310 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-06-15 14:29 UTC by Max Sauer
Modified: 2013-06-28 18:16 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Max Sauer 2007-06-15 14:29:27 UTC
I dont like the way the current reformatter removes blank lines in my source code. I (and surely a large number of
developers) use blank lines also to logically structure my code, and all of these spaces created for better orientation
get deleted upon each reformat. 
There should be at least a checkox inside Options dialog, which would enable 'old-style-do-not-delete-my-blank-lines' mode.

---
Product Version: NetBeans IDE Dev (Build 070615) 
Java: 1.6.0_02-ea; Java HotSpot(TM) Client VM 1.6.0_02-ea-b02 
System: Linux version 2.6.12-1.1390_FC4smp running on i386; 
UTF-8; en_US (nb) Userdir: /home/ms159439/.netbeans/dev
Comment 1 Vitezslav Stejskal 2007-06-18 03:47:34 UTC
Btw, it contradicts issue #103831.
Comment 2 Jan Becicka 2007-08-20 15:17:05 UTC
I prefer to keep blank lines. Anyway P4 imo.
Comment 3 mclaassen 2007-09-05 17:13:38 UTC
I appreciate idea of making blank lines fit to a standard, but there needs to be a way to turn this off.  Maybe a check
box in that options panel to 'never remove blank lines' or something.  There are LOTS of places in my code where I use
blank lines to separate things (for instance, a classes final fields from the non-final ones).  This just helps me
quickly see the grouping, by not really worthy of a comment.

I am using daily build 200709050000 and was getting pretty frustrated.  Because the "real-time" formatter is not quite
using my settings, I am using the "Reformat Code" action a lot.  In so doing I kept on wondering why certain items where
not visually separated like I thought they would be.  Then I realized what was happening.

I truly believe that this is going annoy many people.  If someone took the time to section their code this way and then
the IDE removed the lines and they didn't realize it, they might start throwing things.  

Granted, one might say it would be better to section for code with comments, rather than blank lines.  And desired blank
lines could be created with a // in front of them so the editor will not remove them.  Still, for code that has been
already written, I think people are going to be upset.

Please change the priority of this issue and address it some fashion soon.  I love Netbeans (especially the promise of
NB6), and I would hate for someone trying it out to get annoyed.

Comment 4 mclaassen 2007-09-05 21:47:52 UTC
Now that I have some more expierence with it, it seems that it does not remove blank lines inside methods.  The blank
lines that I noticed being removed were in some class level field declarations.  

If this is the intended behavior (that it doesn't remove them from methods) then this is not nearly as big a deal as I
had first thought.
Comment 5 Dusan Balek 2007-10-25 11:02:28 UTC
Fixed in the current dev build. Reformatter should preserve explicit newline.
Comment 6 mclaassen 2007-11-15 17:02:55 UTC
I set all the "blank line" values in the options dialog to zero and reformatted.  All blank lines in my source file
(except the ones inside a method) were removed.

Using 6.0 RC1
Comment 7 hansabbink 2007-12-06 13:30:31 UTC
I just started working with NB6 and this and related reformatting issues was the first thing I noticed. Existing code 
that over the years had been hand formatted to f.i. emphasise correlation between methods and/or members by inserting 
blanks, definitly lost quality by reformatting. The same is true for other reformatting issues. I think the problem is 
that if everything is formatted to the same uniform rules, nothing stands out anymore. Our in-house coding rules do 
allow for instance to use a "compact" lay-out for a member with its associated get/set methods. Typically a compact 
block of three lines is sufficient for the member, the get/set methods and their javadoc. Reformatting now inflates 
that into ten or thirteen lines (depending on whether separating blank lines are used or not).  I do appreciate the 
effort that has gone into the improved formatting, but it would be nice to be able to more selectively enable/disable 
individual formatting rules.
Comment 8 Max Sauer 2007-12-06 14:06:14 UTC
Raising to P3...
Comment 9 mclaassen 2008-04-08 19:07:44 UTC
My preferred spacing is:
package
<blank line>
imports
<blank line>
Class name
<blank line>
variable group
  [<blank line>
   variable group]...
<blank line>
First constructor

Netbeans removes most of these blank lines, although some are configurable.

Maybe the option should be "at least X lines" between things.  That way, if I add a line for readability, it is not
removed by the reformatter.
Comment 10 Jiri Prox 2008-04-11 00:51:31 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 11 Jan Becicka 2008-08-05 15:38:42 UTC

*** This issue has been marked as a duplicate of 116078 ***
Comment 12 MikeFHay 2013-04-03 10:50:42 UTC
This bug has not been resolved, and is not a duplicate of bug 116078. There is still no way to have the formatter preserve new lines e.g. between groups of fields.
Comment 13 Dusan Balek 2013-04-05 17:44:59 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/6bd02ebb2a87
Comment 14 Michel Graciano 2013-06-28 18:16:14 UTC
*** Bug 227310 has been marked as a duplicate of this bug. ***