Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How make clang-format indent using tabs instead of spaces?

Tags:

clang-format

Testing with the following

clang-format -style="{BasedOnStyle: Google, UseTab: Always}" -i /path/to/file.ino

Results in spaces instead of tabs

like image 973
WhatsYourFunction Avatar asked Dec 03 '25 15:12

WhatsYourFunction


1 Answers

Internally, clang-format only works with spaces, its not until the final step it replaces spaces with tabs and then it will only replace them in groups of TabWidth. Since the Google style has IndentWidth: 2 and TabWidth: 4 it wont replace them with tabs unless there are two indents on the same line.

You'll have to sync up IndentWidth and TabWidth in addition to UseTab for it to work on every line:

UseTab: Always
IndentWidth: 4
TabWidth: 4
like image 180
Fiskmans Avatar answered Dec 05 '25 23:12

Fiskmans