Never Mix Tabs and Spaces - revisited
I was always in the - use only spaces - group for coding. Until recently, when I started using clang-format. It has many options:
UseTab (UseTabStyle) The way to use tab characters in the resulting file. Possible values: UT_Never (in configuration: Never) Never use tab. UT_ForIndentation (in configuration: ForIndentation) Use tabs only for indentation. UT_ForContinuationAndIndentation (in configuration: ForContinuationAndIndentation) Use tabs only for line continuation and indentation. UT_Always (in configuration: Always) Use tabs whenever we need to fill whitespace that spans at least from one tab stop to the next one.
Now I use the setting: ForIndentation Which uses Tabs for indenting the the block, and if more indentation is required for aligning, then spaces are used. So it doesn't matter wether someone has 2, 4, or 8 spaces per tab, the code is always aligned correctly.
Currently my stance is: use Tab for indenting, use space for aligning.
Having worked in teams where some developers liked to use this mixed tab/spacing as you suggest, I can say in reality it never worked how you thought it should. It only really worked if everyone had the same indentation levels set.
In my IDE (well, it's just vim with some plugins, nonetheless), I have visible tabs and spaces. Hence I have always been an advocate for the tabs-for-indentation, spaces-for-continuation rule, simply because it allowed me to see a visual difference in indented vs continued/aligned code, that is, you can consider this as some sort of syntax highlighting for indentation. I had several other reasons for being an advocate for that style, for example, I had seen lots of misaligned space-only code, like this:
if (cond) {
do_something();
}
whereas misalignment by using tabs is nearly impossible (except your editor/IDE tries to be overly smart); and, of course, the typical reason: people can choose their tab width as they like it to read code.
However, why is my so much beloved rule still a bad idea? It is complex. Simple rules (like: don't use tabs, ever) are (almost) always the best rules. For example, when I explained that rule to others, some had to grasp the concept of indentation vs continuation (vs alignment) first. Complex rules are easier (unwittingly) broken than simple rules. Moreover, misalignment is not much of a thing since things like code review or even automated formatters are around. The flexible tab width argument is a pure theoretical one for many people. Also the default tab width 8 (which is used by many systems) is considered too wide by many people.