# 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).

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | Yes | [§4.6.2 Reset Mode (RM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.2) |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | Yes | [RM](https://vt100.net/docs/vt510-rm/RM.html) |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes | KAM, IRM, SRM and LNM |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | Yes | KAM, IRM, SRM and LNM |
| kitty | 0.49.1, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/kitty.json) | Partly | fails RM-4 of the 4 cases that show it working |
| foot | 1.28.0, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/foot.json) | Partly | fails RM-3, RM-4 of the 4 cases that show it working |
| pyte | 0.8.2, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/pyte.json) | Yes | passes the 3 cases that show it working |
| xterm.js headless | 6.0.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/xtermjs.json) | Partly | fails RM-4 of the 4 cases that show it working |
| alacritty_terminal | 0.26.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/alacritty.json) | Partly | fails RM-4 of the 4 cases that show it working |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | Partly | lists only `20` (LNM) and its own `7`, line wrapping; [ANSI escape codes](https://conemu.github.io/en/AnsiEscapeCodes.html) |
| rxvt-unicode | 9.31, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/urxvt.json) | Partly | fails RM-3, RM-4 of the 4 cases that show it working |
| VTE | 0.84.1, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/vte.json) | Partly | fails RM-4 of the 4 cases that show it working |

## 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>.
