# Reset Mode (RM)

> Turn one or more ANSI modes off.

- **Sequence:** `CSI Pm l`
- **ECMA-48:** [§8.3.106 RM – Reset Mode, p. 56](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n69/mode/1up)
- **DEC STD 070:** [§5.10.1 SM/RM – Set Mode, Reset Mode, p. 5-133](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n387/mode/1up)
- **VT220:** [§4.6.2 Reset Mode (RM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.2)
- **VT510:** [RM—Reset Mode](https://vt100.net/docs/vt510-rm/RM.html)

`CSI Pm l` resets one or more modes, the ones [SM](https://control-codes.page/csi/sm/index.html.md) sets. Each
parameter names one mode, the modes are reset in order, and ECMA-48 gives no
default. The numbers are the [ANSI modes](https://control-codes.page/ansi/index.html.md), and the table on the SM
page says which of them xterm and libghostty-vt keep: KAM, IRM, SRM and LNM.
Every other number is ignored, and DEC STD 070 and the VT220 manual both say
that a `0` is an error, ignored.

ECMA-48 calls the reset state of each mode the first one, and recommends it
as the default, so RM usually puts a mode back the way it started. Not
always: send/receive mode, [SRM](https://control-codes.page/ansi/srm/index.html.md), starts set on DEC terminals
and in xterm, and `CSI 12 l` turns local echo *on*.

RM has one privilege in ECMA-48. In the graphic state of control
representation mode, [CRM](https://control-codes.page/ansi/crm/index.html.md), every control function is shown
rather than performed, except RM, so that `CSI 3 l` can still turn the mode
off. Neither xterm nor libghostty-vt has that state.

ANSI modes and DEC private modes cannot be mixed in one sequence. The DEC
private form, `CSI ? Pm l`, is [DECRST](https://control-codes.page/csi/decrst/index.html.md).

## Validation

### RM-1: Two modes in one sequence

Input, one step per line:

```text
\e[4;20h
\e[4;20l  # IRM and LNM
abc
\e[1;1H
X
\n
Y
```

Expected screen:

```text
|Xbc__|
|_Y___|
cursor 2,3
```

### RM-2: Only the modes it names

Input, one step per line:

```text
\e[4;20h
\e[20l     # LNM only
abc
\e[1;1H
X         # still inserts
\n
Y
```

Expected screen:

```text
|Xabc_|
|_Y___|
cursor 2,3
```

### RM-3: A mode that is not known does not stop the others

Input, one step per line:

```text
\e[4h
\e[0;99;4l # 0 is an error, 99 is no mode
abc
\e[1;1H
X
```

Expected screen:

```text
|Xbc__|
cursor 1,2
```

### RM-4: Resetting SRM turns local echo on

Input, one step per line:

```text
\e[12l
\e[12$p
```

Expected screen:

```text
|_____|
reply \e[12;2$y
```

### RM-5: A question mark makes it a different mode

Input, one step per line:

```text
\e[4h
\e[?4l    # DECSCLM, not IRM
abc
\e[1;1H
X
```

Expected screen:

```text
|Xabc_|
cursor 1,2
```

---

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