DECSCNM
DECSCNM (Mode 5) is a DECSET/DECRST mode that swaps the foreground and background colors of the entire screen, producing a reverse-video (light background) display.
Syntax
CSI ? 5 h DECSET — Enable reverse video (light background)
CSI ? 5 l DECRST — Disable reverse video (normal, dark background)
DECSET-mode5 = 0x1b, "[", "?", "5", "h" ; DECRST-mode5 = 0x1b, "[", "?", "5", "l" ;
Description
Per the VT100 User Guide and VT510 Programmer Reference, DECSCNM (Screen Mode) controls the visual polarity of the display.
- Set (reverse video) — The screen displays dark characters on a light background. The foreground and background colors are swapped for the entire display.
- Reset (normal video) — The screen displays light characters on a dark background. This is the default.
DECSCNM swaps the default foreground and background colors globally. Characters that have already been written with explicit SGR color attributes may appear differently depending on the terminal implementation; some terminals swap all colors, while others only swap the default pair.
On the original VT100 hardware, this mode literally controlled whether the phosphor was illuminated for the foreground or the background, giving the appearance of "white paper" vs "green screen." In modern terminals, the effect is achieved by swapping the configured foreground and background palette entries.
Visual flash
DECSCNM can be toggled rapidly to produce a visible "flash" effect, which is how some terminals implement the visual bell (BEL when the audible bell is disabled).
Examples
printf '\e[?5h' # Enable reverse video (light background)
printf '\e[?5l' # Disable reverse video (dark background)
# Visual flash effect (toggle reverse video briefly)
printf '\e[?5h' && sleep 0.1 && printf '\e[?5l'
Specifications
| Specification | Section |
|---|---|
| VT510 Reference | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✗ | No | |
| Bobcat | ? | ? | Not explicitly configured in Bobcat. TerminalCtrl may support this, but cannot confirm from Bobcat's code. |
| contour | ✓ | v0.1.0 | DECSCNM (mode 5 - reverse video) implemented as DECMode::ReverseVideo in primitives.h line 617, used in Terminal.cpp lines 482, 686 |
| foot | ✓ | Yes | Reverse video mode |
| Ghostty | ✓ | v1.0.0 | Reverse video mode |
| iTerm2 | ✓ | Yes | Reverse video mode via reverseVideo property |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | Reverse video mode (MODE_Screen) for light backgrounds |
| mintty | ✓ | Yes | DECSCNM (Mode 5) reverse video implemented at src/termout.c:2410-2414 |
| mlterm | ✓ | Yes | Fundamental VT100 mode, present since early versions |
| PuTTY | ✓ | 0.45 | Reverse video mode at terminal.c:3083-3099; includes visual bell support |
| Rio | ? | ? | |
| rxvt-unicode | ✓ | 1.2 | PrivMode_rVideo - Reverse video |
| st | ✓ | 0.2 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | DEC_REVERSE_IMAGE mode |
| WezTerm | ✓ | Yes | Reverse video mode |
| Windows Terminal | ✓ | Yes | |
| xterm | ✓ | xterm-1 | DECSCNM (mode 5) - Reverse video |
| xterm.js | ✗ | No | Explicitly marked as unimplemented |
| Multiplexers | |||
| cy | ✓ | Yes | |
| GNU Screen | ✓ | v.4.2.0 | Reverse video mode (src/ansi.c:1103-1107) |
| tmux | ✗ | No | |
| tuios | ✗ | No | |
| Zellij | ✗ | No | |
See also
- Reverse video — SGR 7 — Per-character reverse video attribute