Skip to main content

DECSLRM

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

DECSLRM (Set Left and Right Margins) is a CSI sequence that defines horizontal scrolling margins. It is only active when left/right margin mode (DECLRMM, mode 69) is enabled.

Syntax​

CSI Pl ; Pr s     DECSLRM — Set Left and Right Margins
Formal syntax
DECSLRM = 0x1b, "[", [ Pl, [ ";", Pr ] ], "s" ;
Pl = digit, { digit } ;                 (* left margin, default: 1 *)
Pr = digit, { digit } ;                 (* right margin, default: screen width *)
digit = "0" | "1" | "2" | "3" | "4"
    | "5" | "6" | "7" | "8" | "9" ;

Parameters​

ParameterDescriptionDefault
PlLeft margin column1
PrRight margin columnScreen width

Description​

Per the VT510 manual, DECSLRM sets the left and right margins of the scrolling region. Pl must be less than Pr. The sequence is only recognized when DECLRMM (mode 69) has been enabled via CSI ? 69 h.

When left/right margins are active, the following operations are confined horizontally:

  • Character insertion and deletion (ICH, DCH)
  • Erase operations respect the margins
  • Cursor wrapping at end of line wraps within the margin area
  • Scrolling operations are confined to the rectangular region defined by both vertical (DECSTBM) and horizontal (DECSLRM) margins

CSI s with no parameters resets the left and right margins to the full screen width.

Conflict with SCP​

CSI s is also used for SCP (Save Cursor Position). When DECLRMM (mode 69) is enabled, CSI s with parameters is interpreted as DECSLRM. Applications that need both left/right margins and cursor save should use DECSC/DECRC (ESC 7 / ESC 8) instead of SCP/RCP.

Examples​

printf '\e[?69h'         # Enable left/right margin mode
printf '\e[5;40s' # Set left margin to 5, right margin to 40
printf '\e[?69l' # Disable left/right margin mode

Specifications​

SpecificationSection
VT510 Reference—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✗NoNo evidence of left/right margin support
Bobcat✓0.9.0Supported via TerminalCtrl library
contour✓v0.1.0Requires DECMode::LeftRightMargin to be enabled
foot✗NoNot implemented; CSI s is used for save cursor instead
Ghostty✓v1.0.0Requires mode 69 to be enabled
iTerm2✓YesVT100CSI_DECSLRM token parsed and executed via terminalSetLeftMargin:rightMargin:, requires Mode 69 enabled
Kitty✗NoDECSLRM (CSI s) not supported. CSI s only handles save cursor (ANSI.SYS) and save modes
Konsole✗NoNo left/right margin support found; only top/bottom margins implemented
mintty✓YesDECSLRM (CSI s) at line 3391-3400, requires Mode 69 (lrmargmode)
mlterm✓rel-2_9_0Implemented at vt_parser.c:5879-5890; Requires Mode 69 (DECLRMM) to be enabled
PuTTY✗No
Rio✗NoLeft/right margins not implemented
rxvt-unicode✗NoLeft/right margins not implemented
st✗NoCSI ? r goes to unknown handler; left/right margins not implemented
terminology✓v1.1.0Requires Mode 69 (lr_margins)
VT100✗No
VTE✓YesRequires Mode 69 (DECLRMM) to be set, conflicts with SCOSC on CSI s
WezTerm✓YesDECSLRM implemented as Cursor::SetLeftAndRightMargins. Requires Mode 69 (DECLRMM) to be set. CSI s is ambiguous with save cursor
Windows Terminal✓YesRequires Mode 69 (DECLRMM). Implemented in ITermDispatch.hpp:75 as SetLeftRightScrollingMargins. CSI s is interpreted as DECSLRM when DECLRMM is enabled, otherwise as ANSISYSSC.
xterm✓xterm-406Requires DECLRMM mode enabled
xterm.js✗NoNot implemented; CSI s is used for ANSI save cursor instead
Multiplexers
cy✗No
GNU Screen✗NoLeft/right margins not implemented
tmux✗NoNot implemented for input; CSI s maps to SCP instead; margins feature used only for output
tuios✓v0.0.15Requires Mode 69 (ModeLeftRightMargin) to be set
Zellij✗No

See also​