Hacker News new | ask | show | jobs
by jbri 4602 days ago
The optimal mechanism is to indent with tabs, and align with spaces (that is, you have the same number of preceding tabs as whatever you're trying to align with, and then use spaces from there).

Though setting your editor up to do that automatically is an incredible pain, and it kind of forces you to use a monospace font.

2 comments

Ah, I didn't see the distinction between "indent" and "align."

Anyway, it seems like this system necessitates that the leading white space on a given line must be a mixture of both tab characters (\t) and spaces, unless one sets their editor to insert space characters as tabs (which is standard), and is obviously living in a state of sin.

On every line that is right-aligned, yes. Most lines would have only tabs.
Who isn't using a monospace font for code editing? I didn't even realize this was a thing.
The primary reason people use monospace fonts is historical inertia. It's definitely worth trying out a proportional font if your environment is amenable to it (some tools don't cope particularly well, for sad and disappointing reasons).
I tried doing that. It looks uglier than Sloth from the Goonies.
IIRC, Stroustoup uses a non-monospaced font in his C++ book.