Tabs to Spaces

I was always a proponent of the tabs side on the eternal tabs or spaces war; but recently I decided to swap sides.

For me, it was (and actually still is) quite easy and logical on how to handle tabs and spaces in code: “Tabs for indentation, spaces for alignment”.

Which would look like this, if view-whitespace-characters was enabled in a text editor:

{
   if (var)
   {
      func1(argument1,
      ······argument2)
   }
   else
   {
      func2(argument1,
      ······argument2)
   }
}

But, despite that, my layouts still got messed up surprisingly often when editing; even more so in recent years.

And I often just detected it by incidence: Python would complain when running a script, or blocks of text would do strange jumps when cutting/copying-&-pasting them — or simply seeing it when I was inspecting a file with a “show all characters/whitespace” option on (which I also tended to do more often than in the past, I noticed).

That behavior was almost always related to the smart auto-formatting features of applications like modern IDEs or advanced text editors. (I write ‘related’ instead of ‘caused’, because maybe my way of editing text is simply not compatible or maintream enough to match with those features, who knows.)

A possible workaround would be to disable all these capabilities, in the N different programs that I use for text-related tasks. But some of those gimmicks are actually helpful, so I would need to try and figure out which combination of those features would create the least damage to my formatting; I’d see that as a waste of time.

So, Plan B: Give in to the tabs-to-spaces belief system: 4 characters for tab size and indent size.
And luckily, all the tools that I care about, still offer the capability to use the TAB and SHIFT+TAB keystrokes to indent/unindent text (blocks), so that’s good.

I work now since several weeks with that settings and haven’t yet found any downside.

PS: If you use Microsoft Visual Studio (2019) and switch to spaces and you still get tabs inserted in a file where currently mostly tabs are being used, check this option:
Tools / Options… / Text Editor / Advanced / uncheck “Use adaptive formatting”.