Skip to main content

DECSCNM

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard

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)
Formal syntax
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.

note

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​

SpecificationSection
VT510 Reference—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✗No
Bobcat??Not explicitly configured in Bobcat. TerminalCtrl may support this, but cannot confirm from Bobcat's code.
contour✓v0.1.0DECSCNM (mode 5 - reverse video) implemented as DECMode::ReverseVideo in primitives.h line 617, used in Terminal.cpp lines 482, 686
foot✓YesReverse video mode
Ghostty✓v1.0.0Reverse video mode
iTerm2✓YesReverse video mode via reverseVideo property
Kitty✓Yes
Konsole✓YesReverse video mode (MODE_Screen) for light backgrounds
mintty✓YesDECSCNM (Mode 5) reverse video implemented at src/termout.c:2410-2414
mlterm✓YesFundamental VT100 mode, present since early versions
PuTTY✓0.45Reverse video mode at terminal.c:3083-3099; includes visual bell support
Rio??
rxvt-unicode✓1.2PrivMode_rVideo - Reverse video
st✓0.2
terminology✓v0.1.0
VT100✓Yes
VTE✓YesDEC_REVERSE_IMAGE mode
WezTerm✓YesReverse video mode
Windows Terminal✓Yes
xterm✓xterm-1DECSCNM (mode 5) - Reverse video
xterm.js✗NoExplicitly marked as unimplemented
Multiplexers
cy✓Yes
GNU Screen✓v.4.2.0Reverse video mode (src/ansi.c:1103-1107)
tmux✗No
tuios✗No
Zellij✗No

See also​