java - 使用 Eclipse 格式化程序从 'if else' block 中删除空格

标签 java eclipse eclipse-mars

我目前设置了 Eclipse 格式化程序来格式化“if-else”语句,如下所示:

if(condition) {
  return foo;
}
else{
  return bar;
}

注意条件的右括号和真正 block 的左括号之间的空格 - 我想删除这个空格。

在格式化程序配置文件中,在 Whitespace -> Control statements -> 'if else' 下,没有“after closing parenthesis”选项。在 Blocks 部分,有一个“before opening brace”选项,但这似乎只适用于 false block (并且无论如何都被关闭)。

我一定是在某处遗漏了一个选项 - 我怎样才能关闭这个空白?

我正在使用 Eclipse Mars 4.5.0。

最佳答案

您可以在 Windows -> Preferences -> Java -> Code Style ->formatter -> Edit profile 部分执行此操作

enter image description here


我认为一旦您在下方看到的下拉菜单中选择了其他选项,它就会生效

enter image description here

关于java - 使用 Eclipse 格式化程序从 'if else' block 中删除空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31316039/

相关文章:

java - 运行时生成 spring xml 文件

java - 如何在JAVA中使用API​​创建新用户

android - Eclipse 如何检测我的 Samsung Galaxy SII 以使用 Debian 作为操作系统进行 USB 调试?

java - 无法在自定义对话框中实现 setSingleChoiceItems

eclipse - 无法在 Eclipse Kepler 中安装 PMD

eclipse - 在 Eclipse 中强制执行 JDK8 Doclint

Eclipse:Maven 项目构建器在构建工作区时生成 NullPointerException

java - "java.lang.ClassNotFoundException: org.codehaus.jackson.map.ObjectMapper"在 Eclipse 火星

java - 如何暂时禁用消息监听器

java - 如何从IDE远程上传并执行java程序