如何在 Eclipse 中配置自动格式化?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1392744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:59:45  来源:igfitidea点击:

How do I configure autoformatting in Eclipse?

javaeclipsecode-formattingcode-standards

提问by Margus

I dislike how auto format messes up empty cycle body, like:

我不喜欢自动格式如何弄乱空循环体,例如:

Before

for (int i = 0; isTest(i); i++); 

After

for (int i = 0; isTest(i); i++)
    ;

How to configure eclipse not to do this?

如何配置eclipse不这样做?

回答by tddmonkey

Go to Windows-> Preferences, and in the options table select Java-> Code Style-> Formatter, then configure to your hearts content.

转到Windows-> Preferences,然后在选项表中选择Java-> Code Style-> Formatter,然后根据您的喜好进行配置。

For future reference, in the Preferencesmenu you can just type in a search term to find all options for that term - so just going onto the Preferencesmenu and typing "format" will show you all options

为了将来参考,Preferences您可以在菜单中输入搜索词以查找该词的所有选项 - 因此只需进入Preferences菜单并输入“格式”即可显示所有选项