WhatsYourFunction
WhatsYourFunction

Reputation: 825

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

Testing with the following

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

Results in spaces instead of tabs

Upvotes: 18

Views: 18374

Answers (2)

Fiskmans
Fiskmans

Reputation: 405

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

Upvotes: 18

Changbin Du
Changbin Du

Reputation: 800

You can use the UseTab option, for example:

UseTab: Always
IndentWidth: 8
TabWidth: 8

Upvotes: 11

Related Questions