HT (Horizontal Tab) is ASCII code point 9 (0x09), Unicode U+0009, and a control character. If your code looks fine on your machine but misaligned on a colleague's, tab width differences are almost certainly the cause. HT advances the cursor to the next tab stop — traditionally every eighth column — creating aligned columns without manually inserting spaces. The `\t` escape is universal across C, Python, Java, and nearly every other language, but what it produces depends on context. Editor tab width can be 2, 4, or 8 spaces, so the same file renders differently across machines unless the team enforces settings via `.editorconfig`. Python 3 raises a `TabError` if you mix tabs and spaces for indentation. YAML forbids tabs entirely for indentation, usually with an unhelpful error message. The name is short for "tabulator," a typewriter feature from the late 1800s. Metal clips along a rail defined column positions; pressing the key flung the carriage to the next clip, eliminating the need to count spaces by hand. UTF-8 encodes it as a single byte 0x09, identical to its ASCII value. Unicode classifies it as Cc (Control, Other) under the official name CHARACTER TABULATION. Occasionally confused with VT (U+000B), which advances downward rather than across, and unrelated to fixed-width Unicode spaces like em space (U+2003) — tab is an instruction to jump to a position, not a character with an intrinsic width.
const char *tsv = "id\tname\tage"; // HT separatorschar field_sep = '\t'; // ASCII 9 (0x09)size_t tabs = 0; for (const char *p = tsv; *p; p++) if (*p == field_sep) tabs++; // count fields
Both work; consistency matters most. Tabs are more accessible — users can set their preferred visual width. Spaces guarantee identical appearance everywhere. Most modern projects pick one and enforce it via .editorconfig or a formatter. The 'war' is mostly a meme at this point.
Tabs allow visually impaired developers to increase indentation width (e.g., to 8 spaces) for better readability without changing the file content. Spaces force a fixed width that might be too narrow for some users to visually scan.
A tab character just means 'advance to the next tab stop.' The width of that jump — 2, 4, or 8 columns — depends on the editor/terminal settings. That's why the same file can look perfectly aligned in VS Code but ragged in a GitHub diff.
Most linters (ESLint, Pylint) and editor extensions ('Indent Rainbow') can highlight mixed indentation. The command line tool `grep -P '\t ' filename` can find lines where tabs follow spaces or vice-versa. Enabling 'render whitespace' in your editor is the best preventative measure.
TSV (Tab-Separated Values) uses tabs instead of commas between fields. It's better when your data contains commas (names, addresses, sentences) because tabs rarely appear in real text. The trade-off: TSV files are harder to edit manually since tabs are invisible.
Most editors have a setting for this — VS Code shows it in the status bar. From the command line, 'expand' converts tabs to spaces and 'unexpand' does the reverse. The 'pr -t -e4' command expands to 4-space tab stops. Pick a method and apply it consistently.