On Alignment Tab Characters

One of my pet peeves is the use of tab characters for alignment. Sure, this might have been acceptable in the early days of computing. But it’s really not a good idea any more.

Tabs display differently depending on the settings, since they do not come built-in with an alignment configuration.

Rather, tabs should be used for delimitation. For instance, separating the values in a table with tabs is often superior to doing so with commas.

Tabs should not be used for indentation. This is true of both code and word processor documents. Spaces are much more portable and flexible. The TAB key, on the other hand, is a perfectly reasonable shortcut for an editor to automatically indent code with spaces, or for a word processor to apply the appropriate indented paragraph style.

Multiple tabs should not be used to make tables look “nicer”. It’s the responsibility of the editor to display TSV files in a sane format; using multiple tabs is simply not portable and semantically wrong.

I realize this is a somewhat contentious topic—some people to this day still prefer tabs to spaces for indenting code, for example. My personal view is that indenting code with tabs is utterly ridiculous. I don’t personally see why this is even a debate.

5 thoughts on “On Alignment Tab Characters

  1. It’s the responsibility of the editor to display TSV files in a sane format; using multiple tabs is simply not portable and semantically wrong.

    This is exactly why tabs have merit over spaces in indenting code. By using tabs (a single tab per level of indentation), an editor can be set to display it however the user likes, and the level of indentation (which is what’s important in code) remains portable across platforms.


    • I have heard that argument before, but I’m not convinced. I do not think there is any meaningful benefit to being able to customize the level of indentation you see. A problem introduced is that everyone sees code at a different indentation level; while this might seem like a trivial difference, it can result in strange code wrapping.

      Imagine if the four spaces in the below code were replaced with a tab character. Than what was intended to be


      might render as


      which is not as pleasantly lined up.


      • I concede that point! Certainly for guaranteeing that everyone sees the same thing, spaces are better. (Though with settings for hard and soft wrap, that guarantee isn’t always so golden.) My admiration for tabs is that it enforces an easily interpreted hierarchy when indenting, one which can be somewhat (though not too much) harder to enforce with spaces—admittedly, I find little support for it other than that. (For what it’s worth, I generally use spaces.)


  2. I should also mention that while I would always use spaces for a personal project (unless it’s a language requirement/recommendation to use tabs), I would happily use whatever the existing convention/style guide states for any collaborative projects. Overall, as people love to joke about, the issue of spaces vs. tabs is a very minor one, and usually not worth getting into an argument over.

    Now, vim vs. emacs on the other hand…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s