开发者

Blank line after curly brace in function with uncrustify

开发者 https://www.devze.com 2023-03-29 22:23 出处:网络
I have configured xcode to use Uncrustify to beautify the code. I modified the Uncrustify configuration file and the resulting code is almost as desired.

I have configured xcode to use Uncrustify to beautify the code. I modified the Uncrustify configuration file and the resulting code is almost as desired.

One thing I don't like is the removal of a blank line between a closing curly brace and the next line of code. For example, this is what Uncrustify currently does:

Input:

if (jsonData != NULL)
{
    return [jsonData objectFromJSONData];
}

NSLog(@"Data read");

Current output:

if (jsonData != NULL)
{
    return [jsonData objectFromJSONData];
}
NSLog(@"Data read");

The desired output would be, in this case, the same as the input:

if (jsonData != NULL)
{
    return [jsonData objectFromJSONData];
}

NSLog(@"Data read");

I already played around with nl_after_func_body = true but this doesn't help.


I now managed to get the behaviour I wanted using the following addition to the configuration file:

nl_before_if = force
nl_after_if = force
nl_before_for = force
nl_after_for = force
nl_before_while = force
nl_after_whi开发者_运维百科le = force
nl_before_switch = force
nl_after_switch = force
nl_before_do = force
nl_after_do = force


Try this:

 nl_after_func_body = 2


Try using

nl_after_if = add   # ignore/add/remove/force

In your config.

Inspired by: Blank line after curly brace in function with uncrustify

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号