NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Netbeans removes single empty lines - how to change this behaviour?

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
johnnybaloney



Joined: 14 May 2015
Posts: 5

PostPosted: Wed Jan 04, 2017 11:26 am    Post subject: Netbeans removes single empty lines - how to change this behaviour? Reply with quote

Hi,


As part of "Reformat on Save" Netbeans 8.1 removes single empty lines between single-line comments, is there any way to disable this behaviour?

For example:
Code:

// comment
// disabled code
                         <- I want to keep this empty line
// another comment


I'm fine with collapsing multiple empty lines into one but here the sole empty line gets deleted and I get one blob of a comment which is an undesirable behaviour.


Thanks
Back to top
johnnybaloney



Joined: 14 May 2015
Posts: 5

PostPosted: Wed Jan 04, 2017 11:31 am    Post subject: Reply with quote

Just found a related feature request although what I'm after is a preservation of blank lines rather than automatic appending or prepending of new ones.

If Netbeans does not offer what I need I'll add my comments to the ticket.
Back to top
Bayless Kirtley
Posted via mailing list.





PostPosted: Wed Jan 04, 2017 3:26 pm    Post subject: Netbeans removes single empty lines - how to change this behaviour? Reply with quote

Don't know how to change that but the simple answer is include the // on the
empty line or use the /*...*/ method for multi-line comments.


-----Original Message-----
From: johnnybaloney
Sent: Wednesday, January 04, 2017 5:26 AM
To: address-removed
Subject: [nbusers] Netbeans removes single empty lines - how to change this
behaviour?

Hi,


As part of "Reformat on Save" Netbeans 8.1 removes single empty lines
between single-line comments, is there any way to disable this behaviour?

For example:

Code:

// comment
// disabled code
<- I want to keep this empty line
// another comment




I'm fine with collapsing multiple empty lines into one but here the sole
empty line gets deleted and I get one blob of a comment which is an
undesirable behaviour.


Thanks






-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2016.0.7996 / Virus Database: 4749/13702 - Release Date: 01/03/17
Back to top
johnnybaloney



Joined: 14 May 2015
Posts: 5

PostPosted: Wed Jan 04, 2017 3:57 pm    Post subject: Reply with quote

Thanks for your reply. Yes, I use it as a workaround. However, this is not really the answer. I add blank lines

// to make a clear division between two places in my source code. The two //
//
// break that division.

Having formatted this answer the way it is I see two paragraphs above not three.

Netbeans correctly collapses multiple blank lines between statements (not sure if this is configurable or a default behaviour) however comments (both single line and block) are treated differently and get clustered together.
Back to top
Mike-EE



Joined: 27 Oct 2014
Posts: 5
Location: Chicago, IL

PostPosted: Wed Jan 04, 2017 4:15 pm    Post subject: Reply with quote

It's definitely not an easy thing to find... Smile

Go to "Tools" -> "Options" from the main menu,
then select "Editor" and the "Format" tab,
then select "Java" as the language and "Blank Lines" as the category.

There you will see a list of the maximum and minimum numbers of lines that the editor will uses when it does the format on save.

I think setting each of the "Maximum Preserved Blank Lines" to 1 or more will solve your formatting issues.

Thanks,
Mike
Back to top
EduardKarelEtc



Joined: 12 Jan 2010
Posts: 15
Location: Amsterdam

PostPosted: Thu Jan 05, 2017 6:57 am    Post subject: Netbeans removes single empty lines - how to change this behaviour? Reply with quote

I assume from the code example that the issue is with using the // comment to temporarly remove code.

One way to use the // comment to excluded code is to always include any comment preceding the code lines to be commented out that start with // in these lines. While lines around the comment can remain.

my 2ยข.
Eduard

johnnybaloney wrote:
Quote:

Thanks for your reply. Yes, I use it as a workaround. However, this is not really the answer. I add blank lines

// to make a clear division between two places in my source code. The two //
//
// break that division.

Having formatted this answer the way it is I see two paragraphs above not three.

Netbeans correctly collapses multiple blank lines between statements (not sure if this is configurable or a default behaviour) however comments (both single line and block) are treated differently and get clustered together.




Back to top
johnnybaloney



Joined: 14 May 2015
Posts: 5

PostPosted: Fri Jan 06, 2017 4:00 pm    Post subject: Re: Netbeans removes single empty lines - how to change this behaviour? Reply with quote

Mike-EE wrote:
It's definitely not an easy thing to find... Smile

Go to "Tools" -> "Options" from the main menu,
then select "Editor" and the "Format" tab,
then select "Java" as the language and "Blank Lines" as the category.


Yes, the design of Options menu isn't great, one of the very few things I don't like about Netbeans, and one of the very few things they got right in Eclipse Razz

Unfortunately that particular option does not appear to have any effect on comments. They all get clustered together regardless of the value I put there. I think it's time to head for Bugzilla...
Back to top
Nornimices



Joined: 17 Feb 2017
Posts: 1

PostPosted: Fri Feb 17, 2017 11:39 am    Post subject: Reply with quote

I am not sure about it.
Back to top
Mark A. Claassen
Posted via mailing list.





PostPosted: Fri Feb 17, 2017 9:12 pm    Post subject: Netbeans removes single empty lines - how to change this behaviour? Reply with quote

Tools -> Options -> Editor -> Formatting -> Java
Category: Blank Links

Disclaimer:
The opinions provided herein do not necessarily state or reflect those of Donnell Systems, Inc.(DSI). DSI makes no warranty for and assumes no legal liability or responsibility for the posting.

-----Original Message-----
From: Nornimices [mailto:address-removed]
Sent: Friday, February 17, 2017 6:39 AM
To: address-removed
Subject: [nbusers] Netbeans removes single empty lines - how to change this behaviour?

I am not sure about it.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo