Skip to main content
ansicode

SU / SD — Scroll up / down

Scroll the screen contents up (SU) or down (SD) by N lines without moving the cursor.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[NS (scroll up) \x1b[NT (scroll down)
\\033[\033[1S / \033[1T
\\e[\e[1S / \e[1T
ESC [ESC [ N S / T
hex1b 5b <N> 53 / 54

Description

Final byte `S` = SU (Scroll Up), `T` = SD (Scroll Down). Both shift the scrolling region's contents by N rows (defaulting to 1 if omitted) and fill the exposed rows with blanks; the cursor position is unchanged. SU `\x1b[1S` makes the top row disappear and a blank row appear at the bottom — the inverse of how a fresh line of text scrolls the screen on its own. Scroll-region semantics apply: if DECSTBM (`\x1b[t;b r`) has restricted the region, only those rows scroll.

Spec citation: ECMA-48 §8.3.147 (SU) / §8.3.113 (SD)

Parameters

Sscroll up by N rows
Tscroll down by N rows

Examples

bash
printf 'top\nmid\nbot\033[2S'   # scroll region up 2
python
import sys; sys.stdout.write('\x1b[1S')
go
fmt.Print("\x1b[1S")
javascript
process.stdout.write('\x1b[1S')
c
printf("\x1b[1S");

Terminal support

xterm
yes
Linux console (fbcon)
yes
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
yes
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences

In the family cookbook

CSI cookbook · 5. Margins & scroll region — DECSTBM `r` and DECSLRM `s`