English 中文(简体)
Blank line after curly brace in function with uncrustify
原标题:
  • 时间:2011-08-23 15:11:09
  •  标签:
  • uncrustify

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_while = 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





相关问题
Blank line after curly brace in function with uncrustify

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 ...

ctags multi-line C function prototypes

Is there a way for ctags to handle multiline function prototypes in C? I ve searched around and the --fields=+S is supposed to do multiline prototypes, but I can t get it to work: ctags -x --c-kinds=...

C++ / Uncrustify / Indenting base class specifications

How do I setup uncrustify so that this code: static const class Example : Int1 , Int2 , Int3 looks like this: static const class Example : Int1 , Int2 , Int3 I can not find any ...

Uncrustify spacing issue with macro inside method call

I am attempting to use Uncrustify on a project of mine, but I am running into some issues with spacing changes that it makes when a macro is used as the receiver of an Objective-C message. For example,...

How do I get uncrustify to indent BEGIN_MESSAGE_MAP regions?

I m trying to use uncrustify on a large inherited C++ codebase and I can t figure out how to get it to indent the following code segment like the example here. BEGIN_MSG_MAP(CMyDlg) MESSAGE_HANDLER(...

热门标签