^[control-codes live in libghostty-vt

Control sequences

RM Reset Mode

Turn one or more ANSI modes off.

CSI Pm l
ECMA-48
§8.3.106 RM – Reset Mode, p. 56
DEC STD 070
§5.10.1 SM/RM – Set Mode, Reset Mode, p. 5-133
VT220
§4.6.2 Reset Mode (RM)
VT510
RM—Reset Mode

CSI Pm l resets one or more modes, the ones SM sets. Each parameter names one mode, the modes are reset in order, and ECMA-48 gives no default. The numbers are the ANSI modes, 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, 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, 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.

Validation

RM-1: Two modes in one sequence

\e[4;20h
\e[4;20l  # IRM and LNM
abc
\e[1;1H
X
\n
Y
|Xbc__|
|_Y___|
cursor 2,3

RM-2: Only the modes it names

\e[4;20h
\e[20l     # LNM only
abc
\e[1;1H
X         # still inserts
\n
Y
|Xabc_|
|_Y___|
cursor 2,3

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

\e[4h
\e[0;99;4l # 0 is an error, 99 is no mode
abc
\e[1;1H
X
|Xbc__|
cursor 1,2

RM-4: Resetting SRM turns local echo on

\e[12l
\e[12$p
|_____|
reply \e[12;2$y

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

\e[4h
\e[?4l    # DECSCLM, not IRM
abc
\e[1;1H
X
|Xabc_|
cursor 1,2
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.