5

I've looked through a couple of posts related to this but they don't seem to help me solve my problem. I have a project where the java files are indented with a 2-space width. I would like to change everything to 4-space width. I tried the "correct indentation" option but it just moves everything back to a 2-space width when I modify a few lines to 4-space indentation. I've checked settings in Java->Code Style->Formatter and the default is 4-space width. I've also checked settings at General->Editors->Text Editors and they are set to 4-space tab width.

I thought the correct indentation may have been reading the whole java file and correcting the code so it conforms to everything else in the file, so I manually modified every line to have 4-space width indentation. Autocorrect indentation still takes everything back to 2 spaces. Has anyone had this problem before? Is there another setting to change?

Josh Bradley
  • 4,630
  • 13
  • 54
  • 79
  • Sounds strange. Are you using Tab to indent and set the tab-size to 2 or using 4-spaces to indent? – ntalbs Feb 04 '13 at 10:04
  • Have you tried simply re-importing your code formatter (i.e. change and change back) – Bob Flannigon Feb 04 '13 at 13:48
  • What do you mean by re-importing the code formatter? You probably don't mean this, but after I make the changes, I have done Eclipse->Restart to close everything out, save the settings, and open up again. Still no luck though. – Josh Bradley Feb 04 '13 at 21:14
  • New answer with additional info: https://stackoverflow.com/questions/1650652/changing-editor-tab-width-in-eclipse-3-5/58494110#58494110 – Gabriel Staples Oct 21 '19 at 21:08

1 Answers1

5

I found the solution. The project-specific settings had the indentation width set to 2, not 4. These settings must have overridden the eclipse settings.

Josh Bradley
  • 4,630
  • 13
  • 54
  • 79
  • Is this for FORMATTING text (i.e. modifying), or for DISPLAY (i.e. read only). Mine still has the issue you described but the project-specific setting doesn't have anything for display width, only the formatter. – Sridhar Sarnobat Mar 29 '18 at 18:50