# Cursor Next Line (CNL)

> Move the cursor down n lines, to the start of the line.

- **Sequence:** `CSI Pn E`
- **Defaults:** Pn = 1
- **ECMA-48:** [§8.3.12 CNL – Cursor Next Line, p. 35](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n48/mode/1up)
- **VT510:** [CNL—Cursor Next Line](https://vt100.net/docs/vt510-rm/CNL.html)

Move the cursor `Pn` lines down and to the first character position of that
line. A `0` is taken as `1`.

It is a [CUD](https://control-codes.page/csi/cud/index.html.md) followed by a [carriage return](https://control-codes.page/c0/cr/index.html.md), and
behaves as those two do. The cursor stops at the bottom margin, or the last
line if it started below the margin, and never scrolls. With left and right
margins set, it goes to the left margin rather than the first column.

DEC STD 070 does not define CNL. The VT510 manual does, as does xterm.

## Validation

### CNL-1: The next line

Input, one step per line:

```text
\e[1;3H
\e[E
X
```

Expected screen:

```text
|_____|
|X____|
|_____|
```

### CNL-2: n lines down

Input, one step per line:

```text
\e[1;3H
\e[2E
X
```

Expected screen:

```text
|_____|
|_____|
|X____|
```

### CNL-3: Stops at the bottom margin, without scrolling

Input, one step per line:

```text
A
\e[1;3r   # region is lines 1 to 3
\e[2;3H
\e[9E
X
```

Expected screen:

```text
|A____|
|_____|
|X____|
|_____|
```

### CNL-4: To the left margin

Input, one step per line:

```text
\e[?69h   # allow left and right margins
\e[2;4s   # margins at columns 2 and 4
\e[1;3H
\e[E
X
```

Expected screen:

```text
|_____|
|_X___|
```

---

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