Vlad Papko
Vlad Papko

Reputation: 13312

Uncrustify: Remove double and more empty lines in ObjC code

So basically I have such code:

NSString *const SomeKey = @"SomeKey";


@implementation SomeClass


- (void)doSomeWork {
    [self startDoingSomeWork];



    [self stopDoingSomeWork];
    [self notifySomeWorkDone];
}

I need this code to be auto-formatted to this form:

NSString *const SomeKey = @"SomeKey";

@implementation SomeClass

- (void)doSomeWork {
    [self startDoingSomeWork];

    [self stopDoingSomeWork];
    [self notifySomeWorkDone];
}

So basically I need to replace all double, triple and etc empty line with single empty line.

Is there any Uncrustify option to enable it?
If No, then do you know any workaround for this scenario?

Upvotes: 3

Views: 585

Answers (2)

Vlad Papko
Vlad Papko

Reputation: 13312

Finally I found correct option for that.
Just add this line to your configuration file:

nl_max = 2

Upvotes: 5

Kevin
Kevin

Reputation: 17586

If Uncrustify doesn't support that feature you could try ClangFormat.

MaxEmptyLinesToKeep: 1 will keep at most 1 empty line.

Source: Line breaks between function definitions

Upvotes: 1

Related Questions