Changing Tabs to Spaces in Eclipse
Let’s say you are developing a high performance code using Eclipse on Windows, than you deploy it to Unix Server, which FTPs some of the code to IBM’s z/OS… Let’s just say you do
It is obvious that these different operating systems use different editors and might even use (z/OS - EBCDIC) different character encodings… That is where incorrect formatting/indentation can decrease readability and maintainability tremendously…
Here is one quick tip on how to ensure that indentation stays the same across all the systems/editors:
use spaces instead of tabs
Here is how to change the default Eclipse “tabbing behavior” to the unified “spacing” one. Some people refer to it as changing “Hard TABs to soft TABs”:
1. Open the default workspace in Eclipse (open Eclispse
) and go to “Window -> Preferences -> Java -> Code Style -> Formatter”

2. Click on “Show” button (if you previously edited this profile the button caption will be “Edit”)

and change the “Tab Policy” from “Tabs only” to “Spaces only”
3. Click “Ok”, choose the name for this profile and save it

You are all set and ready for “indentational independence”
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
February 7th, 2008 at 4:05:24
Sweet - I was off and running in no time!
July 20th, 2008 at 15:37:59
thanks for the tip, tabs for indentation is some mistake, hopefully can be fixed
December 3rd, 2008 at 17:11:49
When you select a block of lines and hit tab to indent the block, Eclipse ignores the ’spaces only’ setting and inserts tab characters. This is a bug.