I admit: I’m a ‘space’ person. What I mean is that I prefer ‘spaces’ over ‘tabs’ in my source code. Why? Because I don’t want to relay on the tab width, and I prefer to use ‘two spaces for an intention level’.
I would assume that maybe half of the world is for spaces, and half of the world is for tabs. I don’t want to cause a religious war here. I’m for freedom of choice, and this is what Eclipse and CodeWarrior for MCU (which is Eclipse based) offers. Now as I have outed myself as a ‘spacer’, and given the fact that CodeWarrior comes as ‘tabser’ by default, this is something I have to change as a setting for my workspace. Here is what I do….
Show White-Space Characters
A useful thing is to show tabs and spaces in the source view. For this I use this toolbar button:
If it is not present, that button is added with the menu Window > Customize Perspective:
That button makes the tabs and spaces visible in the source view:
Tabs for Spaces
Being a ‘spacer’, I want to use tabs to insert spaces. For this there is a preference under the menu Window > Preferences > General > Editors > Text Editors:
The next thing to do is to define my own Code Style. For this go the Preferences and go into C/C++ > Code Style and press Edit:
This offers a dialog where I can specify the Tab policy and the Intention size:
As noted in the bottom of above dialog: I have modified a built-in profile, and I’m not allowed to change it. So I specify my Coding Style Profile and Press OK:
Now the Editor is using spaces instead of tabs, with the given intention level (number of spaces for tabs).
This of course will only apply to new source changes. Existing tabs are not affected. But there is an easy way to convert tabs into spaces (with the right plugin).
AnyEdit Tools and Plugin
For any advanced manipulation of spaces and tabs, I recommend the AnyEdit Tools which offers really cool features. It offers a powerful automatic conversion of tabs and spaces:
If you are a ‘spacer’ or a ‘tabser’: it does not matter, Eclipse is a perfect choice for both worlds. And allows you to easily switch sources from one world to another. And don’t worry that you have to apply settings for every workspace: see Copy My Workspace Settings which helps to apply them to multiple workspaces.
Happy Spacing :-)