^[control-codes
live in libghostty-vt

Control sequences

EL Erase in Line

View as Markdown

Erase part or all of the cursor's line.

CSI Ps K
Defaults
Ps = 0
ECMA-48
§8.3.41 EL – Erase in Line, p. 42
DEC STD 070
§5.11 Erase in Line, p. 5-154
VT220
§4.12 Erasing
VT510
EL—Erase in Line

Erase some of the line the cursor is on, chosen by Ps:

PsErases
0from the cursor to the end of the line, the cursor’s cell included
1from the start of the line to the cursor, the cursor’s cell included
2the whole line

The cursor does not move, and as with ED, erased cells take the current background color. CSI K is what a shell prints to clear the rest of a line it is redrawing.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.12 Erasing
VT510manual, 1st ed., 1993YesEL
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMYespasses the 3 cases that show it working
foot1.28.0, run in a VMYespasses the 3 cases that show it working
pyte0.8.2, run as a libraryYespasses the 3 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 3 cases that show it working
alacritty_terminal0.26.0, run as a libraryYespasses the 3 cases that show it working
ConEmubuild 230724, its documentationYesits list has 2 also move the cursor to the first column; ANSI escape codes
rxvt-unicode9.31, run in a VMYespasses the 3 cases that show it working
VTE0.84.1, run as a libraryYespasses the 3 cases that show it working

Validation

EL-1: To the right

\e#8      # fill with E
\e[2;3H
\e[K
|EEEEE|
|EE___|
|EEEEE|
cursor 2,3

EL-2: To the left

\e#8      # fill with E
\e[2;3H
\e[1K
|EEEEE|
|___EE|
|EEEEE|

EL-3: The whole line

\e#8      # fill with E
\e[2;3H
\e[2K
|EEEEE|
|_____|
|EEEEE|

EL-4: With a background color

ABCDE
\e[1;3H
\e[41m    # red background
\e[K
|AB___|
attr 1,2 bg=default
attr 1,3 bg=1
attr 1,5 bg=1
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.