How to show/reveal hidden or invisible characters in NetBeans? - netbeans

How can you show/reveal hidden characters in NetBeans? In other editors, if this feature is turned on, a space might be shown as a small centered dot, and a tab as a right arrow. (This feature is useful to see if a file uses tabs or spaces for indentation, among other things.)

This feature was missing for a long time—a feature request was created on November 1999 and it was finally implemented on August 2010 (NetBeans 6.10). You can enable/disable it at "View → Show Non-printable Characters".
Bug history
As of NetBeans 7.0.1, the definition for "non-printable" seems to include tabs and carriage returns but not regular white space char:
NetBeans 7.1.0 finally displays spaces. However, now it has a new bug where consecutive tabs (or tabs & spaces combinations) collapse into one tab:
NetBeans 7.4.0 fixes this:
There're yet a couple of issues:
The end of file is represented with the same symbol as line feeds, thus making it non-obvious to determine whether the file ends with EOL.
Hidden chars are displayed in the same colour as regular text.
These issues have not been addressed so far but they can be sort of mitigated with the Editor Whitespace third-party plugin, which:
Hides the EOL and EOF markers (which aren't useful anyway).
Displays other whitespace characters using always the same colour.

in netbeans 7 you can enable display of spaces, tabs & line feeds like this:
spaces
download font from: http://netbeans.org/bugzilla/attachment.cgi?id=97902
install the ttf font
tools > options > font & colors > Syntax > All Languages > Whitespaces
choose the installed whitespace font
more info about the netbeans 6 bug: http://netbeans.org/bugzilla/show_bug.cgi?id=4619
tabs & line feeds
in netbeans 7 you can enable to see non-printable characters:
view > show non-printable characters
in netbeans 6 only the spaces part works

Using Netbeans 8.0.1
View-> Show Non-Printable characters

Ubuntu 11.10 => Netbeans 7.0.1
The "View → Show Non-printable Characters" mode really not shows whitespaces while font was not installed by me.
Thanks!

View -> Show Non-Printable characters

Using Netbeans 7.3.1,
View -> Show Non-Printable characters
I can see white-spaces, tabs, and carriage returns.

This feature has finally been added and is available in NetBeans 6.10. Since this has not been released yet, you can try out 6.10 MileStone 1: http://bits.netbeans.org/netbeans/6.10/m1/. I look forward to the final release!

Related

Show non-print characters in NetBeans less vividly

NetBeans has an option to show non-printable characters, but they are shown with the same vividness as printable characters. This means that a space and a dot are very hard to distinguish: the space is slightly raised, but otherwise visually identical. Many other code editors, and even Gedit, will show non-printing characters greyed out. Is there an option to do this in NetBeans, or do I have to file a bug report?
There is a different (and better) solution compared to my other answer, based on feedback from the OP: download and install the the Editor Whitespace plugin.
Its download page shows that it has not been tested for any version of NetBeans more recent than 8.0, but I have checked that it still works with NetBeans 8.2 and NetBeans 11.2.
To use the plugin:
Click the Download button on the plugin page to install the plugin in some arbitrary location.
In NetBeans: Tools > Plugins > select the Downloaded tab
Click the Add Plugins... button, navigate to the downloaded plugin, click Open, then click Install.
There is no need to restart NetBeans after installing the plugin. Just check the menu option View > Show Non-printable characters to immediately see non-printable characters in source code, excluding line break (¶) characters.
By default the non-printable characters are shown as black dots, but you can use any other color instead:
Tools > Options > Fonts & Colors > Syntax
Select All Languages from the Language drop list, and Whitespace from the Category list. You can select a specific language form the drop list if you prefer.
Using the Foreground drop list, pick the color you want to use to show the dots representing non-printable spaces.
Select Custom... to create your own color if you don't like any of the standard options.
The only benefit to using the plugin is that it suppresses the display of line break (newline) characters, but that is definitely worthwhile. If you have a specific requirement to be able to see line break characters, don't install this plugin, and just use standard NetBeans functionality as described here.
You can change the font color of whitespace characters to any color you want, either for a specific language, or for all languages. Here's how to do it for Java on NetBeans 9:
Tools > Options > Fonts & Colors > Syntax
Select Java from the Language drop list, and Whitespace from the Category list.
Using the Foreground drop list, pick the color you want to use to show the dots representing non-printable spaces. Select Custom... to create your own color if you don't like any of the standard options. As you scroll through the options for Foreground the color of the dots representing printable spaces in the Preview screen change.
Here's a shot showing the color being changed to magenta:
Notes:
The approach described above does not change the color of the line break character at the end of each line, and I don't think that is possible. That is arguably a bug, and at least a missing feature.
Although you can change the Foreground color at any time, it is only relevant when View -> Show Non-printable Characters is checked. Checking that option is also necessary to see the whitespace characters in the Preview screen.
The Background color for Whitespace can also be modified, but the result is invariably ugly and unhelpful.

Convert tabs into spaces

Many editors and IDEs support converting spaces into tabs by using Tab/Shift+Tab on a line or a selected text fragment, but I've not found such a feature in Eclipse. Is there a plugin or something to add such functionality? I've tried to find one myself, but it doesn't seem to have any by keywords like "tab" or "indent". I'm working with Perl, BTW.
Check if the context menu has an entry like Source->Correct Indentation. That is available for Java, but the availability depends on the language you edit.
Otherwise you can install the AnyEdit Tools plugin which provides a command to convert the selection from tabs to spaces and vice versa.
If you change settings to tabs only or spaces only, Tab, Shift + Tab works as expected. (At least for me).

Eclipse indentation issues

(Note: this is a self answered question and I just wanted to share my experience)
Working with Eclipse Juno 4.2.2 I set the general editor to indent code with 4 spaces. However, I wanted to indent html files with only 2 spaces and changed the HTML editor to use spaces and a length of 2 but nothing seemed to take effect because it was always indenting using 4 spaces. So, what was the problem?
To solve this, I just restored default settings in the default editor (using 1 tab) and everything just worked as expected: The Java editor and PyDev are set to indent with 4 spaces and html editor is set to indent with 2 spaces. This seems to be a bug in Eclipse.
Cheers.

how to align tabs (whitespaces) on github when using eclipse

within eclipse when using inline comments // i do, for my sake, align all the comments at the same position using tabulator, i.e:
$this->site=new openRTB_site($mixed->site); //See Site Object
$this->device=new openRTB_device($mixed->device); //See Device Object
but when i commit to github and see the file there, some of my lines got broken like:
$this->site=new openRTB_site($mixed->site); //See Site Object
$this->device=new openRTB_device($mixed->device); //See Device Object
how can i handle this in comfort way? (not using external white space parser)
example of my broken file here: https://github.com/ulkas/openRTBphp4/blob/master/openRTBphp4.php
The problem is that GitHub shows each TAB as 8 spaces :)
I can only think in two solutions:
change your editor to show each TAB as 8 spaces
change your editor to use spaces instead of TAB
A must have Eclipse tool for dealing with these type of whitespace issues is AnyEdit tools. Especially the Tabs > Spaces and Spaces > Tab conversion features could be useful for your situation.

Show control characters in Netbeans 6.5

Is it possible, to show control characters in NetBeans 6.5?
Like carrige return, spaces or tabs etc.
I searched for it in each menupoint but didn't find an option for that.
Check this: View -> Show Non-printable Characters
For this version of Netbeans this feature does not exist. The best thing you / I can do is useing the search to find spaces or tabs. Netbeans will mark them.