在Eclipse中的空块之前删除新行 [英] Removing new lines before empty blocks in Eclipse

查看:121
本文介绍了在Eclipse中的空块之前删除新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更喜欢



解决方案

据我所知, ;您可以指定何时应插入新行,但是大括号上的配置优先。如果你对此感到强烈,并且不要鄙视IDE注释,你可以使用:

  @formatter:off 
SomeDefaultCtor(){}
@formatter:on

这些必须在eclipse格式化。


I prefer Allman-style braces, for example:

if (foo)
{
    // magical prancing unicorn stuff
}

rather than:

if (foo) {
    // unmagical boring pony things
}

The Java formatter in Eclipse handles this pretty well, except for empty code blocks, which it formats like this:

SomeDefaultCtor()
{}

I'd like to use this special format for empty blocks instead:

SomeDefaultCtor() {}

Is there any way to tell Eclipse to leave braces on the same line when the braces surround an empty code block? So far, I can't see one:

解决方案

As far as I can tell this is not (yet) possible in eclipse; you can specify when new lines should be inserted or not but the configuration on the braces takes priority. If you feel strongly about this and do not despise IDE annotations for this you could use:

@formatter:off
SomeDefaultCtor() {}
@formatter:on

These must be enabled in the eclipse formatter.

这篇关于在Eclipse中的空块之前删除新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆