一千萬個為什麽

如何讓Eclipse為Java內容輔助插入制表符而不是空格？

（編輯：幾張海報都指出了Java/Code Style/Formatter/Indentation/Tab策略，它被設置為“Tabs only”）

At the moment I have to remember to select them and re-format with ++.

最佳答案

1. Go to Project->Properties.
2. In the resulting box, go to "Java Code Style"->Formatter.
3. Click the "Configure Workspace Settings" link in the upper right of the box.
4. Click the Edit button next to the name.
5. Change "Tab policy:" drop down box to "Spaces only" because tabs are evil and inevitably result in poorly formatted code. >:-( This is also where you can actually affect the indentation size and tab size in your files.
6. You will need to change the "Profile name" at the top of the box to save your changes.
7. Thankfully, once you hit "OK", Eclipse will use your profile for your current project, so you're done after this step.