# Horizontal Tab (HT)

> Move the cursor right to the next tab stop.

- **Sequence:** `HT`
- **ECMA-48:** [§8.3.60 HT – Character Tabulation, p. 45](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n58/mode/1up)
- **DEC STD 070:** [§5.4.5 Horizontal Tab, p. 5-67](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n321/mode/1up)
- **VT510:** [4.2 Control Characters](https://vt100.net/docs/vt510-rm/chapter4.html#S4.2)

Move the cursor right to the next tab stop. If there is no tab stop between
the cursor and the right margin, the cursor goes to the right margin and stops
there: a tab never wraps onto the next line.

The cells passed over are left as they are, not filled with spaces. A
terminal that copies its screen as text usually turns the run of empty cells
back into spaces, or into the tab itself, but on the screen there is nothing
there.

Tab stops start out every eight columns (columns 9, 17, 25 and so on) in
libghostty-vt and most other terminals. `CSI ? 5 W` restores those, [HTS](https://control-codes.page/esc/hts/index.html.md)
sets one at the cursor, and [TBC](https://control-codes.page/csi/tbc/index.html.md) clears them. [CHT](https://control-codes.page/csi/cht/index.html.md) moves forward
several tab stops at once and [CBT](https://control-codes.page/csi/cbt/index.html.md) moves back.

## Validation

### HT-1: To the next tab stop

Input, one step per line:

```text
\e[?5W    # reset tab stops
A\tB
```

Expected screen:

```text
|A_______B___________|
cursor 1,10
```

### HT-2: From exactly on a tab stop

Input, one step per line:

```text
\e[?5W    # reset tab stops
\e[1;9H   # column 9 is a tab stop
\t
X
```

Expected screen:

```text
|________________X___|
```

### HT-3: Stops at the right margin

Input, one step per line:

```text
\e[?5W    # reset tab stops
\t\t\t\t
X
```

Expected screen:

```text
|___________________X|
|____________________|
cursor 1,20
pending-wrap yes
```

---

This is the Markdown version of <https://control-codes.page/c0/ht/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
