Santoshkumar Kalasa
Santoshkumar Kalasa

Reputation: 497

.clang-format option to customize spacing

I want to configure clang-format to add space after function name and before opening parentheses only for the function definition.

SpaceBeforeParens: Always

this option put space for every if,for loop and function call.

Is there anyway to customize it to put space only when function definition not to put space in case of function call,for,if. I need something as below.

function definition

  int foo () 
  {
    return 0;
  }

function call. (Note there is space between function name and parentheses)

foo();

Upvotes: 5

Views: 3414

Answers (2)

Jacob gidron
Jacob gidron

Reputation: 9

i just found it myself in clang documentation https://clang.llvm.org/docs/ClangFormatStyleOptions.html

BreakBeforeBraces: Custom
BraceWrapping:
  AfterFunction : true
true:
void foo()
{
  bar();
  bar2();
}

false:
void foo() {
  bar();
  bar2();
}

Upvotes: 0

Santoshkumar Kalasa
Santoshkumar Kalasa

Reputation: 497

Unfortunately there is no way to do that thing into only function.

Upvotes: 3

Related Questions