DECSLRM
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
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
| Parameter | Description | Default |
|---|---|---|
Pl | Left margin column | 1 |
Pr | Right margin column | Screen 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
| Specification | Section |
|---|---|
| VT510 Reference | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✗ | No | No evidence of left/right margin support |
| Bobcat | ✓ | 0.9.0 | Supported via TerminalCtrl library |
| contour | ✓ | v0.1.0 | Requires DECMode::LeftRightMargin to be enabled |
| foot | ✗ | No | Not implemented; CSI s is used for save cursor instead |
| Ghostty | ✓ | v1.0.0 | Requires mode 69 to be enabled |
| iTerm2 | ✓ | Yes | VT100CSI_DECSLRM token parsed and executed via terminalSetLeftMargin:rightMargin:, requires Mode 69 enabled |
| Kitty | ✗ | No | DECSLRM (CSI s) not supported. CSI s only handles save cursor (ANSI.SYS) and save modes |
| Konsole | ✗ | No | No left/right margin support found; only top/bottom margins implemented |
| mintty | ✓ | Yes | DECSLRM (CSI s) at line 3391-3400, requires Mode 69 (lrmargmode) |
| mlterm | ✓ | rel-2_9_0 | Implemented at vt_parser.c:5879-5890; Requires Mode 69 (DECLRMM) to be enabled |
| PuTTY | ✗ | No | |
| Rio | ✗ | No | Left/right margins not implemented |
| rxvt-unicode | ✗ | No | Left/right margins not implemented |
| st | ✗ | No | CSI ? r goes to unknown handler; left/right margins not implemented |
| terminology | ✓ | v1.1.0 | Requires Mode 69 (lr_margins) |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | Requires Mode 69 (DECLRMM) to be set, conflicts with SCOSC on CSI s |
| WezTerm | ✓ | Yes | DECSLRM implemented as Cursor::SetLeftAndRightMargins. Requires Mode 69 (DECLRMM) to be set. CSI s is ambiguous with save cursor |
| Windows Terminal | ✓ | Yes | Requires 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-406 | Requires DECLRMM mode enabled |
| xterm.js | ✗ | No | Not implemented; CSI s is used for ANSI save cursor instead |
| Multiplexers | |||
| cy | ✗ | No | |
| GNU Screen | ✗ | No | Left/right margins not implemented |
| tmux | ✗ | No | Not implemented for input; CSI s maps to SCP instead; margins feature used only for output |
| tuios | ✓ | v0.0.15 | Requires Mode 69 (ModeLeftRightMargin) to be set |
| Zellij | ✗ | No | |
See also
- DECSTBM — Set Top and Bottom Margins — Vertical scrolling margins
- SCP/RCP — Save/Restore Cursor — Shares the
CSI ssequence