Cydouzo
Cydouzo

Reputation: 525

Clang-format : default "Indent Width" is not 4

I downloaded clang-format-6.0, and for some reason the default Indent Width is 2. I read on several threads that the default indent used by clang-format is 4.

I tried on several projects and on several file types, and its the same.

Now I know that I can add a .clang-format file to change the indent width. But having to do that for all my projects just to set the Indent Width back to default is annoying.

EDIT: Apparently the default is actually 2 ... I guess there must be a reason for this ... choice ¯_(ツ)_/¯ Is there a way to change the default value without having to make .clang-format files everywhere?

Upvotes: 4

Views: 5128

Answers (1)

All The Rage
All The Rage

Reputation: 831

The question appears to be "Is there a way to change the default value without having to make .clang-format files everywhere?"

Yes, you can configure clang-format on the command line as well. In this case:

clang-format -style="{IndentWidth: 4}"

And you can make a shell alias so that you don't have to type that whole thing:

alias cf 'clang-format -style="{IndentWidth: 4}"'

Upvotes: 2

Related Questions