# Character Position Backward (HPB)

> Move the cursor left n columns.

- **Sequence:** `CSI Pn j`
- **Defaults:** Pn = 1
- **ECMA-48:** [§8.3.58 HPB – Character Position Backward, p. 45](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n58/mode/1up)

Move the cursor `Pn` columns to the left, on the line it is on. A `0` is
taken as `1`.

ECMA-48 defines it, as the counterpart of [HPR](https://control-codes.page/csi/hpr/index.html.md), for the *data*
component, which a terminal does not have apart from its screen (§6, p. 14).
Neither the VT510 manual nor xterm's documentation lists it, and xterm
ignores it: its parse table sends `CSI … j` straight back to the ground
state ([`VTPrsTbl.c`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/VTPrsTbl.c#L609-L612)). The cases follow xterm, as
the [sources](https://control-codes.page/sources/index.html.md) page explains, and expect the cursor not to move.

libghostty-vt implements HPB as [CUB](https://control-codes.page/csi/cub/index.html.md): the same final-byte handler
serves both, so it moves the cursor left as ECMA-48 describes. That makes
every case below a known difference.

## Validation

### HPB-1: Ignored, with the default

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
ABCD
\e[j      # ECMA-48: one column left
X
```

Expected screen:

```text
|ABCDX|
```

### HPB-2: Ignored, with a count

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
ABCD
\e[3j     # ECMA-48: three columns left
X
```

Expected screen:

```text
|ABCDX|
```

### HPB-3: Ignored, with a count past the first column

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
ABC
\e[99j    # ECMA-48: as far left as the first column
X
```

Expected screen:

```text
|ABCX_|
```

---

This is the Markdown version of <https://control-codes.page/csi/hpb/>. 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>.
