Skip to main content

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​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓0.1.0Supported via ClearMode::Saved for erasing scrollback
Bobcat✓0.9.0Supported via TerminalCtrl library
contour✓v0.2.0.171_rc2Clears scrollback buffer via _grid.clearHistory()
foot✓YesED 3 (erase scrollback) at csi.c:994-998
Ghostty✓v1.0.0
iTerm2✓YesED 3 (erase scrollback) handled in VT100CSI_ED case with parameter 3 via terminalClearScrollbackBuffer
Kitty✓YesED 3 (CSI 3 J) erases scrollback, implemented in screen.c:2529-2530
Konsole✓YesED 3 (CSI 3 J) clears history at src/Vt102Emulation.cpp:2023
mintty✓YesED 3 (CSI 3 J) at line 3183-3187, clears scrollback buffer
mlterm✓rel-2_9_0Clears scrollback by resetting log size at vt_parser.c:5663-5673
PuTTY✓0.59
Rio✓v0.0.3
rxvt-unicode✗NoOnly modes 0, 1, 2 supported; mode 3 not implemented
st✗NoCSI 3 J not implemented; ED only handles parameters 0, 1, and 2
terminology✓v1.0.0
VT100✗No
VTE✓YesImplemented in erase_in_display() as case 3, calls drop_scrollback()
WezTerm✓YesED 3 (erase scrollback) implemented as EraseInDisplay::EraseScrollback
Windows Terminal✓YesScrollback erase implemented via EraseType::Scrollback at DispatchTypes.hpp:372 and handled in adaptDispatch.cpp:742
xterm✓xterm-406Requires eraseSavedLines resource enabled
xterm.js✓2.5.0
Multiplexers
cy✗NoOnly ED 0, 1, and 2 are implemented
GNU Screen✗NoCSI J explicitly rejects parameter > 2
tmux✓1.7ED 3 (CSI 3 J) clears scrollback history
tuios✓v0.0.15
Zellij✓v0.10.0

See also​