如果在NetBeans中,则在一行中没有大括号 [英] No braces around one-line if in NetBeans

查看:81
本文介绍了如果在NetBeans中,则在一行中没有大括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完成一些代码之后,或者当其他人将代码推送到存储库后,我希望对代码快速运行NetBeans的代码格式.除了一件事,我已经设法根据自己的需要对其进行了自定义;

After I'm done writing some code, or when someone else has pushed code to the repository, I like to quickly run NetBeans' code formatting over the code. I've managed to customise it to my needs, except for one thing;

当在代码中时...

if ($a == $b)
    $c = $d;

... NetBeans将按照以下格式重新格式化;

... NetBeans will reformat it as follows;

if ($a == $b)
{
    $c = $d;
}

我认为,这只会降低代码的可读性.我已经弄乱了代码格式化首选项,但是我没有找到执行此操作的选项.

In my opinion, it just makes the code less readable. I've messed around in the code formatting preferences, but I haven't found an option to do this.

那么我如何告诉NetBeans的代码格式化程序不要在由单行组成的if语句周围添加括号(或者,如果理想的话,甚至不要删除它们)?

So how do I tell NetBeans' code formatter to not add braces (or even remove them if they're there, ideally) around if statements that consist of a single line?

推荐答案

我知道这个问题很旧,但是这个答案可能有用. 我使用NetBeans 11.2进行Java代码编程,并且遇到了同样的问题",经过一番搜索,我在工具>选项>编辑器中找到了它:

I know this question is old, but this answer could be useful. I'm using NetBeans 11.2 for programming Java code and I had same "problem", after little search I found this in Tools > Options > Editor:

这篇关于如果在NetBeans中,则在一行中没有大括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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