7

I've followed all the suggestions here.

When I press return, I get a new line that is indented with tabs instead of spaces.

If I backspace to clear the tabs, and then press TAB a series of times, it correctly indents with spaces.

I'm pretty sure I have all my settings set up correctly. I created a new Code Style > Formatter policy for every language in the project, and specified to always use spaces. It seems as though these settings are partially active (ex: when I press tab), but inactive when I use return. I tried restarting Eclipse. I'll try restarting the computer now...

I'm using Mac OS X 10.9.2 and a Liferay Developer Studio (1.6.3.v201312111844) version of Eclipse (not sure which Eclipse build its based on though).

Can anyone think of another setting/solution to ensure that newlines are created with spaces instead of tabs? I recently saw http://editorconfig.org/, and I'm wondering if there's some interference.

Thanks for any suggestions

Community
  • 1
  • 1
Michael Lewis
  • 4,252
  • 6
  • 28
  • 39

1 Answers1

4

If the file has existing lines that are using tabs, then Enter will respect that and try to create new lines in a similar way (see this comment by topchef for a solution). Also, it could be something in Liferay Studio's proprietary settings is overriding Eclipse standard preferences (as suggested by user John).

Keep in mind that each type of editor in Eclipse can have its own preferences and perhaps that's what you're running into here. You can try to find them all by opening Preferences and searching for "indent" in the search field. That will show all the preferences pages where indentation can be configured.

enter image description here

Also note that the Formatter settings don't have any affect on as-you-type formatting; that's for when you select a file or group of files or part of a file and choose Source > Format from the menu.

Community
  • 1
  • 1
E-Riz
  • 31,431
  • 9
  • 97
  • 134
  • 1
    Which settings control the 'as-you-type' settings? I've changed everything I've found, maybe I missed something. I did Source > Format the whole file, saved it, restarted, etc. It's still not working.. – Michael Lewis May 09 '14 at 18:36
  • See the additions I made to my answer. – E-Riz May 09 '14 at 18:43
  • 1
    Thanks for the screen. I found those "Typing" settings, and they're set appropriately. I reformatted my code and there are no tabs. It still doesn't work - but I'll give up for now – Michael Lewis May 09 '14 at 18:57
  • 1
    Whew! Got it. Just as I was about to give up, here's a potential tip for anyone else who finds this: Go to `General > Editors > File Associations` to figure out which editors are enabled for various file types. I had an Aptana editor active, which had its own Tabs/Spaces setting. I changed literally 5-6 different `Editor > Formatter` settings before I found the right one. – Michael Lewis May 09 '14 at 19:03
  • @E-Riz It looks like the **Formatter** settings do affects as-you-type formatting. Eclipse was auto indenting a new line when I hit _return_ using a four-space tab. Once I modified the settings in the **Formatter**, Eclipse started indenting by two spaces. This is on _Eclipse Neon_. This should be rechecked as I was messing with a number of settings. – Steve Nov 15 '16 at 18:20