简体   繁体   English

在Eclipse中格式化if-else

[英]Formatting if-else in eclipse

is there any way to format if-else statement in Eclipse where multiple conditions come in each line while pressing Ctrl + Shift + F ? 有什么方法可以格式化Eclipse中的if-else语句,其中在按Ctrl + Shift + F的同时在每一行中都有多个条件? I tried to fiddle around in Preferences -> Java -> Code Style -> Formatter , but was not able to find the right option to get it working. 我试图在Preferences -> Java -> Code Style -> Formatter摆弄,但是找不到正确的选项来使其正常工作。

The format that i am trying to achieve is as follows. 我正在尝试实现的格式如下。

if(condition1 == true
       && condition2 == true
       && condition3 == true
       && condition4 == true
       && condition5 == true) {
    return 0;
}

Any suggestions? 有什么建议么?

严格用括号括起来的所有条件都可以。

May be your requirement adjusted in below confirguration. 可能会在以下配置中调整您的要求。

Preferences -> Java -> Code Style -> Formatter -> Edit 首选项-> Java->代码样式->格式化程序->编辑

在此处输入图片说明

遗憾的是,您无法使用“代码样式”->“格式化程序”来完成您想做的事情,但是是的,括号内的编写将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM