DECSCNM — Reverse video screen mode (CSI ? 5 h / l)
Globally swap foreground and background colours for the entire screen — the screen-wide reverse-video toggle, distinct from per-cell SGR 7.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[?5h (reverse) \x1b[?5l (normal)\033[?5h / \033[?5l\e[?5h / \e[?5lESC [ ? 5 h / ESC [ ? 5 l1b 5b 3f 35 68 / 6cDescription
Screen Mode (Reverse). When set (`\x1b[?5h`), the terminal renders the entire screen with foreground and background colours swapped — every cell appears as `bg-on-fg` instead of `fg-on-bg`, including cells with explicit SGR colours (their fg/bg are individually swapped). Reset (`\x1b[?5l`, the default) returns to normal. This is **distinct from SGR 7** (per-cell reverse video, slug `sgr-reverse`): SGR 7 toggles a single cell's flag, DECSCNM toggles the entire rendering buffer. Use cases: accessibility (some users with photosensitivity prefer light-on-dark and toggle this on a global keybind), demonstration / debugging (flash the whole screen to highlight a state change), retro emulators (DEC VT100s shipped with this exposed as a hardware switch). Implementation note: kitty / alacritty / wezterm / ghostty implement it; some respect it only for the default background pair (cells with explicit colours stay un-swapped, breaking the semantic). Persists until reset, or until DECSTR (soft reset, restores to default) or RIS (hard reset). Don't confuse with the dark-mode / light-mode preference exchange via OSC 11 — OSC 11 changes the default background colour itself, DECSCNM swaps everything visible.
Spec citation: DEC VT100 (DECSCNM) / xterm-ctlseqs
Parameters
Examples
printf '\033[?5h' # global reverse video\nsleep 1\nprintf '\033[?5l' # back to normalimport sys, time\nsys.stdout.write('\x1b[?5h'); sys.stdout.flush()\ntime.sleep(0.1) # 100ms flash for state change\nsys.stdout.write('\x1b[?5l')fmt.Print("\x1b[?5h") // reverse on\ndefer fmt.Print("\x1b[?5l") // always reset on exitprocess.stdout.write('\x1b[?5h') // honour user's accessibility-flash preferenceprintf("\x1b[?5h"); /* whole screen reverse */\nprintf("\x1b[?5l"); /* back to normal */Terminal support
- xterm
- yes
- Linux console (fbcon)
- yes
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- 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 | yes | yes | yes | yes | no | yes | yes | yes | yes | yes | yes | no | no |