RI
RI (Reverse Index / Reverse Line Feed) is a C1 control function that moves the cursor up one line in the same column, scrolling the screen down if the cursor is at the top margin of the scrolling region.
Syntax
ESC M RI — Reverse Index (7-bit)
0x8D RI — Reverse Index (8-bit C1)
RI = ( 0x1b, "M" ) | 0x8d ;
Description
Per ECMA-48 §8.3.104, RI "causes the active presentation position to be moved in the presentation component to the corresponding character position of the preceding line."
If the cursor is at the top margin of the scrolling region (set by DECSTBM), the screen scrolls down: all lines within the scrolling region move down one position, the line at the bottom margin is lost, and a new blank line appears at the top margin.
If the cursor is above the scrolling region or on the first line of the display, RI has no effect.
RI is the inverse of IND (Index). Together they provide symmetric single-line scrolling within the scrolling region.
Examples
printf '\eM' # Move cursor up one line (scroll down if at top margin)
Specifications
| Specification | Section |
|---|---|
| ECMA-48 | §8.3.104 |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | ESC M listed as IMPLEMENTED in docs/escape_support.md; handler reverse_index() at term/mod.rs:1861 |
| Bobcat | ✓ | 0.9.0 | Reverse index, handled in TerminalCtrl library |
| contour | ✓ | v0.1.0 | ESC M implemented in processSequence; calls reverseIndex() |
| foot | ✓ | Yes | Implemented in vt.c:513-514 as ESC M |
| Ghostty | ✓ | v1.0.0 | ESC M handled in stream.zig:2202-2211 |
| iTerm2 | ✓ | Yes | |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | |
| mintty | ✓ | Yes | Handled in do_esc() at src/termout.c:1967-1972 |
| mlterm | ✓ | rel-0_2_1 | |
| PuTTY | ✓ | 0.45 | |
| Rio | ✓ | v0.0.28 | |
| rxvt-unicode | ✓ | rxvt-unicode-1.2 | |
| st | ✓ | 0.4 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | |
| WezTerm | ✓ | Yes | Handled in performer.rs:458 via ControlCode::RI and esc.rs:40 as EscCode::ReverseIndex |
| Windows Terminal | ✓ | Yes | ESC M dispatches ReverseLineFeed() in OutputStateMachineEngine.cpp:223-224 |
| xterm | ✓ | Yes | Implemented in charproc.c:5468 via RevIndex() |
| xterm.js | ✓ | 3.5.0 | |
| Multiplexers | |||
| cy | ✓ | v0.1.0 | |
| GNU Screen | ✓ | v.4.2.0 | RI (ESC M) implemented in DoESC() at src/ansi.c:718 |
| tmux | ✓ | 1.3 | Reverse index via screen_write_reverseindex() |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.5.0-beta | |
See also
- IND — Index — Move cursor down one line (the inverse of RI)
- SU/SD — Scroll Up/Down — Scroll by a specified number of lines
- DECSTBM — Set Top and Bottom Margins — Defines the scrolling region