在Eclipse中注释之后没有换行符

Gar*_*son 6 java eclipse format comments alignment

我一直是一个"对齐花括号"的人.对于宽屏显示器,我在代码后添加了很长的注释.所以在Eclipse中我想做这样的事情:

if(foo)
{
  something();
}
else
{
  somethingElse();
}
Run Code Online (Sandbox Code Playgroud)

精细; 这很简单.但后来我添加评论:

if(foo)  //if foo is true
{
  something();
}
else  //if no foo
{
  somethingElse();
}
Run Code Online (Sandbox Code Playgroud)

Dratted Eclipse将其格式化为:

if(foo)  //if foo is true
{
  something();
}
else
//if no foo
{
  somethingElse();
}
Run Code Online (Sandbox Code Playgroud)

大.那整个浪费的线.它看起来很难看.它甚至不精确,因为我想评论这else条线.

我如何让Eclipse格式化我的if/ else使用对齐的大括号,但允许我的注释与同一行else

这是在Eclipse 4.2.2上测试的,我刚刚确认它在Eclipse 4.3M7中也不起作用.

我已就此问题提出了错误 ; 让我们看看Eclipse开发人员要说些什么.

joa*_*ima 0

在 Eclipse 配置文件中,注释选项卡上有一个选项“保留代码和行注释之间的空白”,您可以尝试一下,看看它是否有效

编辑:

我想我明白了:在格式编辑中,转到Braces选项卡并将Blocksas放入Same line。因为我在这里改变了很多,所以我不确定这是唯一需要的。但这是必要的。上面也有标注Insert new line before else in an ifControl Statements