^[control-codes
live in libghostty-vt

Escape sequences

RI Reverse Index

View as Markdown

Move the cursor up one line, scrolling down at the top margin.

ESC M
ECMA-48
§8.3.104 RI – Reverse Line Feed, p. 55
DEC STD 070
§5.4.3 Reverse Index, p. 5-36
VT220
§4.7 Cursor Positioning
VT510
4.2 Control Characters

The mirror image of a line feed: move the cursor up one line, keeping its column. If the cursor is on the top margin, the lines of the scrolling region move down by one instead: the bottom line leaves the region, and a blank line appears at the top.

This is how a full-screen program scrolls backwards, a line at a time, without redrawing what is already on the screen.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.7 Cursor Positioning
VT510manual, 1st ed., 1993YesTable 4–2
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMYespasses the 3 cases that show it working
foot1.28.0, run in a VMYespasses the 3 cases that show it working
pyte0.8.2, run as a libraryYespasses the 3 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 3 cases that show it working
alacritty_terminal0.26.0, run as a libraryYespasses the 3 cases that show it working
ConEmubuild 230724, its documentationYesESC M, listed as a reverse \n, in ANSI escape codes
rxvt-unicode9.31, run in a VMYespasses the 3 cases that show it working
VTE0.84.1, run as a libraryYespasses the 3 cases that show it working

Validation

RI-1: Up one line

\e[3;2H
\eM
X
|_____|
|_X___|
|_____|

RI-2: Scrolls down at the top

A\r\nB\r\nC
\e[1;1H
\eM
X
|X____|
|A____|
|B____|

RI-3: Within a scrolling region

1\r\n2\r\n3\r\n4
\e[2;3r   # region is lines 2 and 3; homes the cursor
\e[2;1H
\eM
X
|1____|
|X____|
|2____|
|4____|
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.