# Erase in Line (EL)

> Erase part or all of the cursor's line.

- **Sequence:** `CSI Ps K`
- **Defaults:** Ps = 0
- **ECMA-48:** [§8.3.41 EL – Erase in Line, p. 42](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n55/mode/1up)
- **DEC STD 070:** [§5.11 Erase in Line, p. 5-154](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n408/mode/1up)
- **VT510:** [EL—Erase in Line](https://vt100.net/docs/vt510-rm/EL.html)

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

| `Ps` | Erases |
| --- | --- |
| `0` | from the cursor to the end of the line, the cursor's cell included |
| `1` | from the start of the line to the cursor, the cursor's cell included |
| `2` | the whole line |

The cursor does not move, and as with [ED](https://control-codes.page/csi/ed/index.html.md), erased cells take the
current background color. `CSI K` is what a shell prints to clear the rest of
a line it is redrawing.

## Validation

### EL-1: To the right

Input, one step per line:

```text
\e#8      # fill with E
\e[2;3H
\e[K
```

Expected screen:

```text
|EEEEE|
|EE___|
|EEEEE|
cursor 2,3
```

### EL-2: To the left

Input, one step per line:

```text
\e#8      # fill with E
\e[2;3H
\e[1K
```

Expected screen:

```text
|EEEEE|
|___EE|
|EEEEE|
```

### EL-3: The whole line

Input, one step per line:

```text
\e#8      # fill with E
\e[2;3H
\e[2K
```

Expected screen:

```text
|EEEEE|
|_____|
|EEEEE|
```

### EL-4: With a background color

Input, one step per line:

```text
ABCDE
\e[1;3H
\e[41m    # red background
\e[K
```

Expected screen:

```text
|AB___|
attr 1,2 bg=default
attr 1,3 bg=1
attr 1,5 bg=1
```

---

This is the Markdown version of <https://control-codes.page/csi/el/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
