White Space or not, that’s the question

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 🙂

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.