DCH — Delete Character (CSI Pn P)
Delete N cells at the cursor and shift the rest of the line left to fill the gap — the inverse of ICH.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[PnP\033[PnP\e[PnPESC [ Pn P1b 5b <Pn> 50Description
Delete Character. Final byte `P` (0x50) removes `Pn` cells starting at the cursor (default 1) and shifts every cell to the right of that range left by `Pn` columns; the `Pn` cells that appear at the right edge are blank (SP, 0x20) with the current SGR background. The cursor itself does not move. DCH is what `vim`/`emacs` emit when you backspace mid-line, what `less` uses to remove the bottom-of-screen prompt, and the primitive readline edits the prompt with. Pair with ICH (`\x1b[Pn @`). DCH stops at the right margin set by DECSTBM column-margins (if active) — cells past the margin are not pulled in. Terminfo cap: `dch1` (Pn=1) or `dch` (parameterised).
Spec citation: ECMA-48 §8.3.26 (DCH)
Examples
# Print 'Hello world', move cursor to column 6, delete 6 cells.\nprintf 'Hello world\033[6G\033[6P' # leaves 'Hello' followed by trailing blanksimport sys; sys.stdout.write('\x1b[3P')fmt.Print("\x1b[3P")process.stdout.write('\x1b[3P')printf("\x1b[3P");Terminal support
- xterm
- yes
- Linux console (fbcon)
- yes
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- partial
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | yes | yes | yes | yes | partial | yes | yes | yes | yes | yes | yes | no | no |
Related sequences
In the family cookbook
CSI cookbook · 6. Insert / delete / cursor shape — IL / DL / ICH / DCH / ECH + DECSCUSR