Questions tagged [uncrustify]

Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA

Uncrustify is an open source project, with a goal to create a highly configurable, easily modifiable source code beautifier.

Features :

  • Ident code, aligning on parens, assignments, etc
  • Align on '=' and variable definitions
  • Align structure initializers
  • Align #define stuff
  • Align backslash-newline stuff
  • Reformat comments (a little bit)
  • Fix inter-character spacing
  • Add or remove parens on return statements
  • Add or remove braces on single-statement if/do/while/for statements
  • Supports embedded SQL 'EXEC SQL' stuff
  • Highly configurable - 515 configurable options as of version 0.63
144 questions
1
vote
1 answer

Configuring uncrustify to add braces

I'm using version of 0.66.1 of uncrustify, and am puzzled by the behavior of 'mod_full_brace_if' which I've set to 'force'. Its comment says: Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an…
user888379
  • 1,343
  • 12
  • 30
1
vote
1 answer

Adding newline after if-else block using uncrustify

Is there a way to introduce a new line after if-else block? Current code looks like this: if (condition) { } else { } if (condition) { } statement; I want to make it look like this: if (condition) { } else { } if (condition) { } statement; I…
Anupam Srivastava
  • 789
  • 1
  • 8
  • 25
1
vote
0 answers

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(WM_TIMER, OnTimer) …
Harvey
  • 5,703
  • 1
  • 32
  • 41
1
vote
2 answers

Uncrustify: how do I set the indentation of the initializer list and function arguments

I have been trying to get an indentation for the constructor which looks like this: ClassName::ClassName(const std::string &id, std::shared_ptr object, bool isDynamic) : m_id(id), …
thenor
  • 21
  • 2
1
vote
1 answer

How to reset code formatting with Uncrustify

I am using Uncrustify to formatting my C++ code and I am making some experiments with infinite list of settings. Because of some bad settings my code now has a lot of new line that split statement in more lines (mostly due to a short line width). I…
Kill KRT
  • 1,101
  • 2
  • 17
  • 37
1
vote
1 answer

Uncrustify - How do I align trailing comments by two-space gap?

After I applied Atom Beautify on my code using Uncrustify, the trailing comments are aligned as follow: unsigned int redLEDValue = 0; // redLED unsigned int blueLEDValue = 0; // blueLED unsigned int greenLEDValue = 0; //…
philectron
  • 123
  • 2
  • 10
1
vote
0 answers

How do I change Uncrustify configuration to indent variable names to the same column as the function name?

in my school we use a coding convention, which specifies to separate the name of the variable and its type (in C). In emacs, it would look like this : static int calc_dir(t_exe *exe, const int id) { int x0, y0; int …
Theo Pnv
  • 402
  • 5
  • 14
1
vote
0 answers

C++11 member initializer lists

I am wondering if it is possible to configure uncrustify to format C++11 member initialization list. E.g: bar::bar() : m_foo1{10}, m_client_factory{ ClientFactorySafePtr{ new ClientFactory {10, 20, 30}}}, …
28 Thorva
  • 11
  • 2
1
vote
1 answer

Uncrustify: remove space between template angles doesn't work

I'd like to remove space between template angles, for example: void Function (list >); ^ | This space should be removed. For this purpose I use sp_angle_shift =…
Gluttton
  • 5,739
  • 3
  • 31
  • 58
1
vote
1 answer

Can Uncrustify indent multi-line method call in Objective-C?

I want my multi-line method call like this: [self.markAsFinishedButton setBackgroundImage:[UIImage imageWithColor:[UIColor blueButtonColor] andSize:CGSizeMake(1, 1)] forState:UIControlStateHighlighted]; But for now, it looks like…
nickcheng
  • 516
  • 4
  • 22
1
vote
1 answer

How to automatically move trailing comments to the line above?

I am looking for a tool, option, or regex to move trailing comments to above the line they describe. In other words I would like to turn this: a = b; // Assign b to a into this: // Assign b to a a = b; I am currently using uncrustify to clean up a…
kcghost
  • 256
  • 1
  • 11
1
vote
1 answer

Comments that control uncrustify behaviour

In this question (https://stackoverflow.com/questions/15097501/can-uncrustify-be-prevented-from-modifying-certain-sections-of-code) i learned that i can use *INDENT-OFF* to exclude uncrustify action on certain parts of code. Unfortunately i was not…
RedX
  • 14,749
  • 1
  • 53
  • 76
1
vote
0 answers

indent_ctor_init_leading of uncrustify do not work

I want the data member has four spaces after ":", so I set indent_ctor_init_leading as 4. But it always give me two spaces expected results : predictor::predictor() : is_human{false}{} true results(only 2 spaces) : predictor::predictor() : …
StereoMatching
  • 4,971
  • 6
  • 38
  • 70
1
vote
0 answers

Uncrustify Objective-C space between open brace and variable arguments

Just wondering if there's some uncrustify options to format the following: - (void) fooTheBarsWithString: (NSString *) string, ...{ Like this: - (void) fooTheBarsWithString: (NSString *) string, ... { This just seems to be an issue with variable…
binarymelon
  • 904
  • 2
  • 12
  • 26
1
vote
0 answers

Is there an uncrustify option to prevent aligning on the end paren?

How do I prevent uncrustify from aligning my method definitions on the end paren? I have this interface file @import UIKit; @protocol MyProtocol @required - (BOOL)isEditing; - (BOOL)isValid; - (NSInteger)numberOfItems; -…
Jonathan Beebe
  • 5,241
  • 3
  • 36
  • 42