Is there any way to persuade Eclipse to use tabs instead of spaces for indenting its built-in Java content assist proposals (such as when creating an empty method which over
Yet another solution that "worked for me" even if the other solutions didn't work (Version: 3.8.1):
Preferences > Java > Code Style > Formatter > Edit > Indentation > Use spaces to indent wrapped lines - Set unchecked
This is essentially the "smart tabs" option. It works for the formatter, but it incorrectly sets code generation into using spaces only. Annoyingly, the solution breaks the formatter.
Have a look in the preferences at Java / Code Style / Formatter
Create your own profile and set "Indentation" / "Tab policy" to "Tabs only"
It seems to be currently a bug (not fixed in the 3.5 train):
bug 44755 (for comments, but also valid for other refactoring JDT operations)
Also linked to bug 231832, involving a bug in the AST rewrite...
I believe this is a problem with
ASTRewrite
, not with the client ofASTRewrite
. We have to make sure that code formatter settings are available for the rewrite part.
Moving toJDT/Core
for investigation.
Detected in late 3.4, still not fixed in 3.5
I found the solution, thanks to Simon Nickerson's comment above, which is what the original poster was referring to in his edit. After having found the setting, I see what they are talking about. However, the way to it was given a few steps from the beginning of the path, so it fails to give a clear answer to people who are new to Eclipse or have been away from it for a few years, like me. so I'll give the full path here:
Now, what's really broken is the fact that these settings override the more up-front interface for changing similar-sounding settings in "Windows/Preferences/General/Editors/Text Editors/Insert spaces for tabs". To someone relatively new to the editor, this would seem like the place to set the default tabs = spaces setting. After finding the real answer, it's clear that this is just for general text editing, and language-specific settings need to be set up in the profiles for the languages at hand. This should be made a bit clearer for noobs, though. ;-)
Preferences > Java > Code Style > Formatter > Edit > Indentation > Use tabs only for leading indentation checkbox
The way I have it setup is to enable the "Format source code" in the Editor->Save Actions preferences.
That way it reformats the source code on save.