I am trying to adjust the width of tabs from Window -> Preferences -> General -> Editors -> Text Editors where there is a field for \"Display Tab Width\". But no matter what
Changing Window -> Preferences -> General -> Editors -> Text Editors tab preference is relevant for text files, not for java files as indicated here. You may create a text file in Eclipse and check that your tab size is really changed.
This setting is superseded for Java by the setting from the Code Style Formatter.
It can be found in Java / Code Style / Formatter (click Edit) / Indentation tab / Indentation
There are multiple places to check and things to do:
click "Edit" button
step, but do it from this menu this time).{
) somewhere. It should go to a new line with the proper indentation you've set above.
{
and you'll see everything works just fine.Version tested: All tested in Eclipse IDE for C/C++ Developers, Version: Oxygen.3a Release (4.7.3a).
Java files have a special place to edit this setting. You need to go to
Window -> Preferences -> Java -> Code Style -> Formatter
And edit the profile.
Check your Java->Code Style->Formatter settings, to see whether you're using tabs or spaces; you might be using spaces!
After digging into this more deeply, I think I've figured this out:
Confusingly, this is under "Formatter" in preferences (like the accepted answer says). But this is inconsistent location-wise with where the option for tab display width for the non-java file Editor is located.
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.indentation.size=16
/instance/org.eclipse.ui.editors/tabWidth=2
I emphasize DISPLAY because this is just for rendering in Eclipse. It does not change the contents of your file, and has no effect on "Source -> Format".