如何使eclipse自动添加大括号到IF语句? [英] How to make eclipse automatically add braces to an IF statement?
本文介绍了如何使eclipse自动添加大括号到IF语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java中,以下是完全有效的:
In Java the following is completely valid:
if (x == null)
Y();
else
Z();
我个人不喜欢。我喜欢我的所有IF语句都有大括号:
I personally don't like it at all. I like all my IF statements to have braces:
if (x == null) {
Y();
} else {
Z();
}
eclipse格式化程序是美好的,可以以许多其他方式美化我的代码。
The eclipse formatter is wonderful and can beautify my code in many other ways.
有没有办法把它添加到IF语句中?
Is there a way to have it add the braces to IF statements?
推荐答案
在首选项下:Java>编辑器>保存操作
Under "Preferences": Java > Editor > Save Actions
1)检查其他操作
2)单击配置...
3)转到代码样式选项卡
3) Go to the "Code Style" tab
4 )检查在if / while / for / do语句中使用块并配置为您的首选项
4) Check "Use blocks in if/while/for/do statements" and configure to your preferences
这篇关于如何使eclipse自动添加大括号到IF语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文