ED 3
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!
Experimental
ED 3 is an XTerm extension to the standard ED (Erase in Display) sequence that clears the scrollback buffer.
Syntax
CSI 3 J ED 3 — Erase scrollback buffer
Formal syntax
ED3 = 0x1b, "[", "3", "J" ;
Description
CSI 3 J erases the scrollback (history) buffer while leaving the visible screen contents intact. This is an extension beyond the standard ECMA-48 ED values of 0, 1, and 2.
Some terminals combine the effects: CSI 3 J clears only the scrollback, while CSI 2 J followed by CSI 3 J clears both the visible screen and the scrollback. Other implementations have CSI 3 J clear everything (both visible and scrollback).
This sequence is commonly used by the clear -x and clear commands (with appropriate terminfo entries) to reset the terminal's scroll history, for example to prevent sensitive information from remaining accessible by scrolling up.
Examples
printf '\e[3J' # Clear scrollback buffer
printf '\e[2J\e[3J\e[H' # Clear screen + scrollback + home
Specifications
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | 0.1.0 | Supported via ClearMode::Saved for erasing scrollback |
| Bobcat | ✓ | 0.9.0 | Supported via TerminalCtrl library |
| contour | ✓ | v0.2.0.171_rc2 | Clears scrollback buffer via _grid.clearHistory() |
| foot | ✓ | Yes | ED 3 (erase scrollback) at csi.c:994-998 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | Yes | ED 3 (erase scrollback) handled in VT100CSI_ED case with parameter 3 via terminalClearScrollbackBuffer |
| Kitty | ✓ | Yes | ED 3 (CSI 3 J) erases scrollback, implemented in screen.c:2529-2530 |
| Konsole | ✓ | Yes | ED 3 (CSI 3 J) clears history at src/Vt102Emulation.cpp:2023 |
| mintty | ✓ | Yes | ED 3 (CSI 3 J) at line 3183-3187, clears scrollback buffer |
| mlterm | ✓ | rel-2_9_0 | Clears scrollback by resetting log size at vt_parser.c:5663-5673 |
| PuTTY | ✓ | 0.59 | |
| Rio | ✓ | v0.0.3 | |
| rxvt-unicode | ✗ | No | Only modes 0, 1, 2 supported; mode 3 not implemented |
| st | ✗ | No | CSI 3 J not implemented; ED only handles parameters 0, 1, and 2 |
| terminology | ✓ | v1.0.0 | |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | Implemented in erase_in_display() as case 3, calls drop_scrollback() |
| WezTerm | ✓ | Yes | ED 3 (erase scrollback) implemented as EraseInDisplay::EraseScrollback |
| Windows Terminal | ✓ | Yes | Scrollback erase implemented via EraseType::Scrollback at DispatchTypes.hpp:372 and handled in adaptDispatch.cpp:742 |
| xterm | ✓ | xterm-406 | Requires eraseSavedLines resource enabled |
| xterm.js | ✓ | 2.5.0 | |
| Multiplexers | |||
| cy | ✗ | No | Only ED 0, 1, and 2 are implemented |
| GNU Screen | ✗ | No | CSI J explicitly rejects parameter > 2 |
| tmux | ✓ | 1.7 | ED 3 (CSI 3 J) clears scrollback history |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.10.0 | |
See also
- ED — Erase in Display — Standard erase operations (Ps = 0, 1, 2)