Reverse video
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
Reverse video (SGR 7) is an SGR attribute that swaps the foreground and background colors of the text.
Syntax
CSI 7 m SGR 7 — Reverse video (negative image)
CSI 27 m SGR 27 — Not reversed (positive image)
Formal syntax
SGR-reverse = 0x1b, "[", "7", "m" ; SGR-not-reverse = 0x1b, "[", "27", "m" ;
Description
Per ECMA-48 §8.3.117, SGR parameter 7 selects "negative image." The foreground and background colors are exchanged so that text appears in the background color on a foreground-colored background.
Reverse is reset by SGR 27 or SGR 0.
Reverse video applies after all other color attributes have been resolved. If the foreground is explicitly set to red and the background to white, reverse video will display white text on a red background.
Reverse video is supported by virtually all terminals and has been available since the VT100.
Examples
printf '\e[7mReversed\e[27m Normal\n'
printf '\e[31;7mReverse red (red background, default fg)\e[0m\n'
Specifications
| Specification | Section |
|---|---|
| VT510 Reference | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | |
| Bobcat | ? | ? | Implemented in external TerminalCtrl library, not in Bobcat source code |
| contour | ✓ | v0.1.0 | |
| foot | ✓ | Yes | Implemented at csi.c:127 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | Yes | Reverse video (SGR 7) fully supported via VT100CHARATTR_REVERSE in VT100GraphicRendition structure. |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | SGR 7 sets RE_REVERSE rendition flag |
| mintty | ✓ | Yes | Implemented at src/termout.c:2148. Sets ATTR_REVERSE flag. |
| mlterm | ✓ | Yes | Supported since early versions |
| PuTTY | ✓ | 0.43 | SGR 7 sets ATTR_REVERSE at terminal.c:4666-4668 |
| Rio | ✓ | v0.0.3 | |
| rxvt-unicode | ✓ | 1.2 | |
| st | ✓ | 0.1 | |
| terminology | ✓ | v0.1.0 | Stored as inverse attribute |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | |
| WezTerm | ✓ | Yes | |
| Windows Terminal | ✓ | Yes | SGR 7 sets reverse video attribute |
| xterm | ✓ | Yes | VT100 feature, supported since earliest versions |
| xterm.js | ✓ | 2.3.0 | |
| Multiplexers | |||
| cy | ✓ | v0.1.0 | |
| GNU Screen | ✓ | v.4.2.0 | SGR 7 mapped to A_RV attribute at src/ansi.c:1703 |
| tmux | ✓ | 0.8 | |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.12.0 | |
See also
- DECSCNM — Screen Reverse Video — Reverse the entire screen