Over a million developers have joined DZone.

White Space or Not, That's the Question

· Performance Zone

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.

There are times when I want to know *exactly* what is inside my source files. In my article on EHEP explains how to get down to the hex bytes of a source file. But in many cases I’m interested to see the non printable/white characters only. Showing white spaces in the sources is easy in Eclipse: I use the ‘Show Whitespace Characters‘ toolbar icon:

Show Whitespace Characters

Show Whitespace Characters

In case that icon is not present in the tool bar, here is how to show it in the toolbar. I use the menu Window > CustomizePerspective and enable it:

Enabling Show Whitespace for Toolbar

Enabling Show Whitespace for Toolbar

I happens to me when I integrating sources from somebody else, that it looks like this: a lot of bytes wasted with white spaces. Not that I’m worried by the disk space used (we have plenty of disk space these days), but these spaces are simply not needed.

Trailing White Spaces in Source File

Trailing White Spaces in Source File

Remove them by hand? Create a regular script expression to have them removed? Nope!

As in my post on Anyedit, there is a plugin which allows advanced editor manipulations, including removal of white spaces. But there is anther way for removing trailing white spaces. Eclipse has an option for that: I go to Window > Preferences > C/C++ > Editor > Save Actions:

Save Action to remove trailing white spaces

Save Action to remove trailing white spaces

Here I can select the option to Remove trailing whitespace. Additionally an option ensures that there is always a newline at the end of the file. And my source files are clean! :-)

:!: Warning: This ‘Save Action’ option does *not* work in Eclipse 3.6 version (which is in CodeWarrior for MCU10.2). But it *does* work in Eclipse 3.7 which is part of MCU10.3 :-)

Happy Spacing :-)

Learn tips and best practices for optimizing your capacity management strategy with the Market Guide for Capacity Management, brought to you in partnership with BMC.


Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}