Skip to main content

DECSED/DECSEL

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

DECSED (Selective Erase in Display) and DECSEL (Selective Erase in Line) are DEC private-mode variants of ED and EL that only erase characters not marked as protected by DECSCA.

Syntax​

CSI ? Ps J    DECSED — Selective Erase in Display
CSI ? Ps K DECSEL — Selective Erase in Line
Formal syntax
DECSED = 0x1b, "[", "?", [ Ps ], "J" ;
DECSEL = 0x1b, "[", "?", [ Ps ], "K" ;
Ps     = "0" | "1" | "2" ;              (* default: 0 *)

Parameters​

ValueMeaning
0From cursor to end (default)
1From beginning to cursor
2Entire display/line

Description​

Per the VT510 manual, DECSED and DECSEL function identically to ED and EL respectively, but only erase characters that were written without the protected attribute. Characters marked as protected (by DECSCA — Select Character Protection Attribute) are left intact.

The ? prefix in the sequence distinguishes these from the standard ED (CSI J) and EL (CSI K).

This feature is used in forms-oriented applications where certain fields (labels, borders) should remain on screen while user-editable areas can be selectively cleared.

Examples​

printf '\e[1"q'      # DECSCA: mark subsequent chars as protected
printf 'Label: '
printf '\e[0"q' # DECSCA: mark subsequent chars as erasable
printf 'user input'
printf '\e[?2J' # DECSED: erase only unprotected characters

Specifications​

SpecificationSection
VT510 Reference—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✗NoNo evidence of selective erase implementation
Bobcat✓0.9.0Supported via TerminalCtrl library
contour✓v0.3.5.238Includes DECSERA support
foot✗NoCSI ? J/K not implemented in csi.c:1469-1623
Ghostty✓v1.0.0Protected mode support via CSI ? J/K
iTerm2✓YesVT100CSI_DECSED and VT100CSI_DECSEL tokens parsed and executed via terminalSelectiveEraseInDisplay and terminalSelectiveEraseInLine
Kitty✗NoDECSED/DECSEL (CSI ? J/K) not supported. Private parameter parsed but DECSCA (character protection) not implemented
Konsole✗NoNo DECSED/DECSEL implementation found; selective erase not supported
mintty✓YesDECSED (CSI ? J) at line 3182, DECSEL (CSI ? K) at line 3198, respects ATTR_PROTECTED attribute
mlterm✓rel-3_0_7Added in commit c45216f1 (2017-06-21); DECSED at vt_parser.c:4976-4998, DECSEL at 4999-5013
PuTTY✗No
Rio✗NoNo evidence of selective erase implementation (CSI ? J/K)
rxvt-unicode✗NoSelective erase not implemented
st✗NoCSI ? J/K not implemented; ED/EL do not check private flag
terminology✗NoExplicitly unsupported, falls back to ED/EL
VT100✗No
VTE~YesImplemented but protected attribute not supported, behaves like ED/EL
WezTerm✗NoDECSED/DECSEL not implemented. SelectiveErase is advertised in device attributes but no CSI ? J/K sequences found
Windows Terminal✓YesDECSED at ITermDispatch.hpp:101, DECSEL at line 102. Both selective erase operations respect DECSCA protection.
xterm✓xterm-406
xterm.js✓5.0.0Requires DECSCA to set protection attribute
Multiplexers
cy✗No
GNU Screen✗NoCSI ? only handles h/l modes, not J/K
tmux✗NoNot implemented; DECSCA protection attribute not supported
tuios✗No
Zellij✗No

See also​