[TUHS] tabs vs spaces - entab, detab

arnold at skeeve.com arnold at skeeve.com
Fri Mar 5 04:31:35 AEST 2021

First, no discussion of this issue would be complete without
this video: https://www.youtube.com/watch?v=SsoOG6ZeyUI

Secondly, there are two issues, only partially related.

1. Do I use real tab characters in my code, or just spaces?

2. How many spaces do I want my editor/IDE to use to (a) display tab
characters or (b) expand tabs into, depending upon my answer to (1)

All *nix systems use a "tab stop" of eight characters when printing
tab characters on a terminal or a line printer.  That is pretty hard
to change.

Traditionalists (or at least, I, speaking for myself) use tabs in
their C, C++, and shell code and *must* use tabs in their Makefiles.

Doing so "saved bytes" on the small machines of yesteryear; that
argument is irrelevant today.

I got used to a tab stop of 8 characters for most code and that's
still my personal preference for the C, C++, awk and shell that I write.

The Python world is different; there the use of spaces and a tab stop
of 4 characters is common.  Fortunately, modern editors / IDEs let
you choose the settings to use based on the language you're editing.

I've used a tab stop of 4 spaces for C++ as well and I find that readable
and pleasant. I find anything less than that to be cramped and unpleasant.

I don't remember the details of entab and detab programs on Unix
(other than the expand command) but "Software Tools" from 1976 had
programs to do those exact two jobs, so the issue of going back and
forth between spaces and tabs has been around for a long time.

The short answer is that what you should do boils down to your
preference(s) and the tools you use to edit code.



Clem Cole <clemc at ccc.com> wrote:

> Oh boy, you do want to pour muddy water on the table.   I generally
> believed in tabs set every 4 spaces.  That's Steven's used in all his UNIX
> books.  Have to ask Rob what and bwk used but I sort of think it was pretty
> similar.  A problem is a lot of people had tabs set at 8 spaces.
> Clem
> On Thu, Mar 4, 2021 at 11:53 AM Will Senn <will.senn at gmail.com> wrote:
> > OK. So, I've been trying to decide (for the last time, I swear) whether to
> > use tabs or spaces in my code... I did a quick pulse-check on the state of
> > argument and it appears to be alive and well in 2021. My question for y'all
> > is, was there a preference in the very early days or not? I saw an article
> > talking about the 20 year feud, but that's not my recollection. In 1994,
> > nobody agreed on this, but I'm sure it predates my entree into the field.
> > I'm thinking the history of entab and detab are somehow related, but I've
> > been wrong on these sorts of thoughts before. What say you?
> >
> > Will
> >

More information about the TUHS mailing list