Hidden NetBeans Feature: Show Spaces in Editor

A really cool feature that I didn't know about until a few hours ago. Go to the main NetBeans menu bar and choose "View | Show Non-printable Characters". And now I can see the spaces in the editor:

The above is in the Java editor. Here is the HTML editor, with spaces:

Really handy to see the spaces (and the carriage returns, as well as the tabs). I made the above discovery while e-mailing with NetBeans Dream Team member Ryan de Laplante. He said that IntelliJ IDEA shows the spaces in the editor, while NetBeans doesn't. Some googling later, I found that NetBeans does, after all, have this support.

It appears that the spaces are visible in the editor for the first time in NetBeans IDE 7.1. At least, I invoked the same action as described above in 7.0.1 and then saw the carriage returns, but not the spaces. (And here's someone else who's found the same thing to be true.)

It's also possible to change the color of the non-printable characters, i.e., you could make them light grey. (But non-printable characters in HTML files do not change color as specified, so that's a bug.) Go to Tools | Options | Fonts & Colors and then go down the Category list until you find "Whitespace". Ryan commented on this that in IntelliJ IDEA "the non-printable characters are shown in a very light shade of grey so I can leave the feature turned on all the time and barely notice it unless I specifically want to look at it. In NetBeans I was able to change the color of the whitespace characters to a light grey too. That would be a nice default."

A second point that Ryan makes about the IntelliJ IDEA implementation of this feature is: "They don't show the line break character… they know that I'm only interested in whitespace characters. Maybe instead of enabling a 'Show non-printable characters' feature, I could enable a 'Show whitespace characters' feature."

And, finally, thus far, I've been unable to distinguish an EOL character from a carriage return (as also pointed out here).

But, clearly, aside from these quibbles, which I think would be nice enhancements for an upcoming release (see the list of issues I added in the comments to this blog entry), it's really great to see the spaces visibly in the editor. Makes it much easier to align one line with the next.

Other support for spaces include Tools | Options | General | Remove Trailing Whitespace, where you can specify under which condition (Never, Always, From Modified Lines Only) the last space, if any, should automatically be removed when the file is saved. Also, if you go to Tools | Options | Formatting | Java | Spaces, you can specify where a space should automatically be entered. (There's a similar option there where you can specify where a blank line, tabs, and indents should automatically be added, e.g., before/after methods, etc.)

NetBeans IDE: where the perfectly customized editor is only a space away...

Comments:

The color of HTML white spaces is ignored: http://netbeans.org/bugzilla/show_bug.cgi?id=205854

EOL is not shown when non-printable characters are shown: http://netbeans.org/bugzilla/show_bug.cgi?id=207508

Want to see white spaces only, not carriage returns: http://netbeans.org/bugzilla/show_bug.cgi?id=207509

Default color of non-printable characters should be light grey: http://netbeans.org/bugzilla/show_bug.cgi?id=207510

Posted by Geertjan on January 18, 2012 at 09:37 PM PST #

The custom color does not work for comments, too. I want it to work, but I wonder if it should. What do you think? Does it need to be developed for each language or is it universal?

Posted by Eduardo Costa on January 19, 2012 at 02:17 AM PST #

Show Non-printable Characters: consecutive tabs display as one: http://netbeans.org/bugzilla/show_bug.cgi?id=207286

Posted by Álvaro G. Vicario on January 19, 2012 at 03:42 AM PST #

Yes, very good. This works when editing PHP.

It's just weird that when I drag the cursor over text it doesn't show trailing white space by default. Visual Studio does it perfectly. Even Hisoft Devpac ST did it 25 years ago.

Posted by Michael Lynn on January 28, 2013 at 03:26 AM PST #

Latest version of netbeans has "trailing whitespaces" on options->fonts & colors -> Highlighting. It's the option. I've changed the background color. Now I finally can see trailing whitespaces.

Posted by guest on March 27, 2014 at 10:42 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today