本文介绍了在Eclipse中的空块之前删除新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我喜欢 解决方案据我所知,在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:offSomeDefaultCtor() {}@formatter:onThese must be enabled in the eclipse formatter. 这篇关于在Eclipse中的空块之前删除新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 00:56