I’ve been using Eclipse to do my CS assignments, as recommended by my professor. However, I’ve noticed that if I open my source code in a different text editor, my beautiful, perfect formatting looks wrong. I believe the problem lies in tabs. A tab character seems to take up less space in eclipse than in other text editors.
A good chunk of our grade is determined by the neatness of our code. I’m not sure if our programs are graded in eclipse or not, so I’d like to figure out how to make source code have the same formatting regardless of text editor.
Is this a problem with Eclipse? Are there settings I can fiddle with?
This is probably due to your settings for the tab symbol. If you really want to indent using tab, make sure it is set to 8 spaces everywhere.
From the Java coding convention:
Personally I always use spaces to indent my code due to the fact that some people have their tab symbol set to show as 4 spaces.
To set Eclipse to always use spaces, go to
Window -> Preferences -> Java -> Code style -> Formatter -> Edit
and set Tab policy to Spaces Only.