Tip:
Highlight text to annotate it
X
Eclipse - spaces vs. TABS
This video will show you how to set up Eclipse
so your code will automatically meet the SCC Java Style Guidelines.
Once you have Eclipse loaded
go into Eclipse Preferences
Go into Java
Code Style and Formatter
You'll see that when Eclipse loads it has a built-in
default settings. You can either edit those
or you can save those as
SCC settings and that would be your
set up. Let's go in and change the built-in settings that come with Eclipse
The first thing you want to do is look over on the right
You'll see the "Show Invisible Characters"
When this is checked you can see all the TABS that are being used to indent the code
We are going to change that TAB policy so there is spaces only.
Change it to three spaces
Every TAB will be three spaces. Over here on the right you can see the spaces.
On the "Braces" section
you can change the braces so the second one goes on the next line.
Here you can see the brace on the next line. I would do that for each of these.
Everything else is pretty much the same all you need to do is change the TAB policy and how the braces display.
Now you'll notice down here at the bottom of the screen that this is
a built-in profile so we have to change this to a new profile name.
I'll call this SCC2
And, as soon as I change the profile name at the top I can go down and click "OK"
If you open up a file you can check things by going into Eclipse/preferences
General/Editors/Text Editors
You'll see where you can insert spaces instead of TABS
You can also turn on line numbers and make sure
"show white space characters" is checked.
We can look at this file we can see that this is a TAB
and two spaces. If we delete that and hit the TAB
that will put our spaces in there.
Or, you can just use the spacebar.
Delete it.....TAB.
And you can see that now are all input as spaces.
And if we do a new line, Eclipse will indent automatically and you can see
that Eclipse is now indenting with spaces.
Ooops, I should have put it inside the curly braces.
So, to do our settings we went into
Java/Code Style/Formatter
and made sure we were at the right profile.
And, if you need to edit your profile you can go in and do that.
And we also looked at the
General/Editors/Text Editors
And we set up our display TAB width, we made sure the settings showed line numbers,
and we show whitespaces.
WebExplorations.com