Skip to main content

SCP/RCP

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard

SCP (Save Cursor Position) and RCP (Restore Cursor Position) are CSI sequences originating from ANSI.SYS that save and restore the cursor position.

Syntax​

CSI s         SCP — Save Cursor Position
CSI u RCP — Restore Cursor Position
Formal syntax
SCP = 0x1b, "[", "s" ;
RCP = 0x1b, "[", "u" ;

Description​

  • SCP (CSI s) — Saves the current cursor position (row and column).
  • RCP (CSI u) — Restores the cursor to the position previously saved by SCP.

These sequences originated in MS-DOS ANSI.SYS and save only the cursor position — not character attributes, character sets, or other terminal state. This is in contrast to DECSC/DECRC (ESC 7 / ESC 8), which saves a more complete snapshot of terminal state.

Conflict with DECSLRM​

CSI s is also used for DECSLRM (Set Left and Right Margins) when left/right margin mode (DECLRMM, mode 69) is enabled. When DECLRMM is set, CSI s with parameters sets the left and right margins rather than saving the cursor. The parameterless form CSI s (no arguments) can be ambiguous in this context, so applications needing both left/right margins and cursor save/restore should use DECSC/DECRC instead.

note

Because DECSC/DECRC saves more state and avoids the DECSLRM conflict, it is generally preferred over SCP/RCP. SCP/RCP remains widely supported for compatibility with ANSI.SYS-era software.

Examples​

printf '\e[s'            # Save cursor position
printf '\e[10;20H' # Move cursor elsewhere
printf 'Hello'
printf '\e[u' # Restore cursor to saved position

Specifications​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓0.1.0Implemented via save_cursor_position/restore_cursor_position
Bobcat✓0.9.0Supported via TerminalCtrl library
contour✓v0.1.0ANSI.SYS style via SCOSC (CSI s) and ANSISYSSC (CSI u)
foot✓YesSCP (s) at csi.c:1250-1252, RCP (u) at csi.c:1254-1256
Ghostty✓v1.0.0Both ANSI.SYS (CSI s/u) and DEC (ESC 7/8) variants
iTerm2✓YesANSICSI_SCP/RCP and VT100CSI_DECSC/DECRC tokens handled via saveCursor/restoreCursor
Kitty✓YesSCP/RCP (CSI s/u) ANSI.SYS style implemented in vt-parser.c:1258-1305
Konsole✓YesANSI.SYS style CSI s/u save/restore cursor at src/Vt102Emulation.cpp:2031-2032
mintty✓YesSCOSC/SCORC (CSI s/u) at lines 3401-3404, uses save_cursor/restore_cursor functions
mlterm✓rel-2_9_0ANSI.SYS style (CSI s/u) at vt_parser.c:5879-5890,5972-5975; Also supports DEC style (ESC 7/8)
PuTTY✓0.45
Rio✓v0.0.3
rxvt-unicode✓1.2Uses CSI s/u (ANSI.SYS), not DEC DECSC/DECRC
st✓0.1ANSI.SYS variant using CSI s/u, not DEC DECSC/DECRC (ESC 7/8)
terminology✓v0.1.0Implemented as CSI s/u (SCOSC/SCORC)
VT100✗No
VTE✓YesImplemented as SCOSC/SCORC for CSI s/u compatibility (not the ECMA-48 SCP)
WezTerm✓YesSCP/RCP (ANSI.SYS style) implemented as Cursor::SaveCursor and Cursor::RestoreCursor, with ambiguity resolution for DECSLRM
Windows Terminal✓YesANSI.SYS cursor restore (CSI u) implemented at OutputStateMachineEngine.cpp:546 as ANSISYSRC_CursorRestore. Note: CSI s can be ANSISYSSC or DECSLRM depending on DECLRMM mode.
xterm✓xterm-406Only available when DECLRMM disabled
xterm.js✓2.3.0CSI s/u (ANSI.SYS style) and ESC 7/8 (DEC style) both supported
Multiplexers
cy✓v0.1.0
GNU Screen✓v.4.2.0
tmux✓1.6SCP (CSI s) and RCP (CSI u) for ANSI.SYS-style cursor save/restore
tuios~v0.0.15CSI s (save) supported, but CSI u (restore) not implemented. Use ESC 7/ESC 8 instead.
Zellij✓v0.10.0ANSI.SYS variant (CSI s/u), not DEC variant (ESC 7/8)

See also​