DECSED / DECSEL — Selective erase display / line (CSI ? Ps J / CSI ? Ps K)
Erase only the unprotected cells in the display (DECSED) or current line (DECSEL) — the private-mode siblings of ED / EL.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[?<Ps>J (DECSED) \x1b[?<Ps>K (DECSEL)\033[?2J / \033[?2K\e[?2J / \e[?2KESC [ ? Ps J / ESC [ ? Ps K1b 5b 3f ... 4a / 1b 5b 3f ... 4bDescription
Identical to ED (\x1b[<Ps>J) and EL (\x1b[<Ps>K) in scope (Ps=0 cursor→end, 1 start→cursor, 2 entire region), but skips cells marked as protected by DECSCA (\x1b[<Ps>"q). DECSCA tags individual character cells as protected (Ps=1) or unprotected (Ps=0 / 2); DECSED and DECSEL are the only erase primitives that honour that tag. Useful for forms — paint immutable labels with DECSCA-protected attribute on, accept user input in unprotected cells, and \x1b[?2K clears only the entry fields without disturbing labels. Outside the forms / data-entry use-case these sequences are vanishingly rare; many modern emulators (alacritty, wezterm, ghostty) treat them as plain ED / EL because they don't track DECSCA at all. Don't reach for these in greenfield code unless you're actually implementing a VT220-style data-entry form.
Spec citation: DEC STD 070 (DECSED / DECSEL) / DEC VT510 RM
Parameters
| Ps | 0 (default) erase cursor → end of region · 1 start of region → cursor · 2 entire region. Protected cells (DECSCA) are skipped. |
Examples
# Erase only unprotected cells on the current line:\nprintf '\033[?2K'import sys\n# Selective ED 2 — keep DECSCA-protected labels intact:\nsys.stdout.write('\x1b[?2J')fmt.Print("\x1b[?0K") // selective EL: cursor to end of lineprocess.stdout.write('\x1b[?2K') // selective EL: whole line, skip protected cellsprintf("\x1b[?1J"); // selective ED: top of screen to cursorTerminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- partial
- iTerm2
- partial
- Windows Terminal
- no
- cmd.exe / ConPTY
- no
- kitty
- no
- alacritty
- no
- WezTerm
- no
- Ghostty
- no
- GNOME Terminal
- partial
- Konsole
- partial
- tmux
- yes
- GNU screen
- yes
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | partial | partial | no | no | no | no | no | no | partial | partial | yes | yes |