the corner office

a blog, by Colin Pretorius

Replacing tabs with spaces in Eclipse

An annoying preference conflict in Eclipse 3.4 (and possibly earlier). I had a problem in that despite having ticked 'Preferences | General | Editors | Text Editor | Insert Spaces for Tabs', my Java code was still being generated with tabs.

Turns out that to really get spaces for tabs functionality, you also have to edit your code formatter options. Maybe the default profile is more intelligent, but I have a custom profile, and I also had to go to 'Preferences | Java | Code style | Formatter', edit my active profile and change 'Indentation | General settings | Tab policy', which had been set to 'tabs only'. Changing this to 'spaces only' solved my problem.

Bah!

{2009.01.21 12:38}

Comments:

1. john celia (2012.05.21 - 16:57) #

I did both, and my code files STILL have tabs. Once you do the above 2 steps, what do you have to do to make it DO the change from tabs to spaces in your source files?

« RIP Tony Hart

» Only human