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

Viewed 2144

Testing with the following

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

Results in spaces instead of tabs

2 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 for it to work on every line:

IndentWidth: 4
TabWidth: 4

You can use the 'UseTab' option, for example:

UseTab: Always
IndentWidth: 8
TabWidth: 8
Related