DECSLRM — Set left and right margins (CSI Pl ; Pr s)
Constrain horizontal cursor movement + scrolling to columns Pl…Pr — the horizontal counterpart of DECSTBM.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[<Pl>;<Pr>s\033[1;80s\e[1;80sESC [ Pl ; Pr s1b 5b ... 73Description
Set Left and Right Margins. Defines a vertical strip — columns `Pl` (leftmost) through `Pr` (rightmost), 1-based, inclusive — within which cursor movement and scrolling are confined. Requires DECLRMM (left-right margin mode, `\x1b[?69h`) to be enabled first; without DECLRMM the sequence is silently ignored, and the final byte `s` instead means SCO save-cursor (this is the parse ambiguity that bites: `\x1b[s` with no params = save cursor, `\x1b[<Pl>;<Pr>s` with 2 params = DECSLRM if DECLRMM=on). Once active, SL/SR scrolling stays inside the strip, CUF/CUB clamp at the boundaries, and writes that hit the right margin wrap to the next row's left margin (instead of column 1). Paired with DECSTBM (`\x1b[<Pt>;<Pb>r`) the two margins define a rectangular scrolling region — the foundation for split-pane editors like vim's `:vsplit` rendering its left half independently of the right. Defaults if omitted: `Pl=1`, `Pr=` last column. Setting `Pl≥Pr` resets to the full screen width.
Spec citation: DEC STD 070 (DECSLRM) / DEC VT510 RM
Parameters
| Pl | Leftmost column (1-based, inclusive). Default 1. |
| Pr | Rightmost column (1-based, inclusive). Default = screen width. |
Examples
printf '\033[?69h' # enable DECLRMM first\nprintf '\033[10;30s' # constrain cols 10..30\n# now scrolling + cursor moves stay within that stripimport sys\nsys.stdout.write('\x1b[?69h') # enable DECLRMM\nsys.stdout.write('\x1b[1;40s') # left margin 1, right 40fmt.Print("\x1b[?69h\x1b[1;40s") // enable + set stripprocess.stdout.write('\x1b[?69h\x1b[1;40s')printf("\x1b[?69h\x1b[1;40s"); /* enable DECLRMM + constrain to cols 1..40 */Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- partial
- Windows Terminal
- no
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- no
- WezTerm
- yes
- Ghostty
- partial
- GNOME Terminal
- no
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | no | partial | no | no | yes | no | yes | partial | no | yes | no | no |
Related sequences
In the family cookbook
CSI cookbook · 5. Margins & scroll region — DECSTBM `r` and DECSLRM `s`