问题
I'm running Eclipse Juno Service Release 2 (20130225-0426) in Windows and I'm finding that auto-indent (Ctrl-I) ignores both the General/Editors/Text Editors/Insert spaces for tabs and Java/Code Style/Formatter/Indentation/Tab policy="Spaces only" settings. With both of those set, Ctrl-I indents the code with a combination of tabs and spaces, even though Ctrl-Shift-F uses spaces only. The problem is I don't want Eclipse to reformat my code -- just correct the indentation with spaces.
Is this a known bug or am I missing a setting somewhere? Thanks!
回答1:
It appears the "Correct Indentation" (Ctrl+I) will attempt to copy whatever indentation was used on the line of code immediately preceding your selected block. (Even if that line is using a combination of tabs and spaces!) If I select the whole file then it actually uses my preferences.
Seems pretty deliberate to be a bug though in my opinion there should at least be an option for it. I looked through the Eclipse bug tracker for a while and didn't see anything.
来源:https://stackoverflow.com/questions/17527819/eclipse-correct-indentation-ignoring-spaces-vs-tabs-setting