Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 715
Cydouzo Avatar asked Oct 28 '25 23:10

Cydouzo


1 Answers

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}"'

like image 198
All The Rage Avatar answered Oct 31 '25 12:10

All The Rage