eclipse conditional formatting braces only for multiple lines

浪尽此生 提交于 2019-12-25 01:06:43

问题


Any way to configure eclipse to only wrap if statements in braces if it is multiple lines, and leave alone single line statements? e.g.

if (x == y) z();

if (x == y){
    z();
}

回答1:


How would it know? If you have a default of always using braces for multiple or single, you will avoid errors of putting in code that is supposed to be part of the if statement but ends up not.




回答2:


Use can use //formatter:off and //formatter:on tags to switch on or switch off formatting in a given range of code lines.

Refer this post: How to use eclipse's code formatter to remove new lines after 'case'?



来源:https://stackoverflow.com/questions/5665247/eclipse-conditional-formatting-braces-only-for-multiple-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!