Skip to main content

ICH/DCH/ECH

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

ICH (Insert Character), DCH (Delete Character), and ECH (Erase Character) are CSI sequences that insert, delete, or erase characters at the cursor position within the current line.

Syntax​

CSI Pn @      ICH — Insert Character
CSI Pn P DCH — Delete Character
CSI Pn X ECH — Erase Character
Formal syntax
ICH = 0x1b, "[", [ Pn ], "@" ;
DCH = 0x1b, "[", [ Pn ], "P" ;
ECH = 0x1b, "[", [ Pn ], "X" ;
Pn  = digit, { digit } ;                (* default: 1 *)
digit = "0" | "1" | "2" | "3" | "4"
    | "5" | "6" | "7" | "8" | "9" ;

Parameters​

ParameterDescriptionDefault
PnNumber of characters to insert/delete/erase1

Description​

These three operations affect characters on the current line only. They do not cross line boundaries.

ICH — Insert Character (CSI Pn @)​

Per ECMA-48 §8.3.64, ICH inserts Pn blank characters at the cursor position. Existing characters from the cursor rightward are shifted to the right; characters pushed past the right margin are lost. The cursor position does not change.

DCH — Delete Character (CSI Pn P)​

Per ECMA-48 §8.3.26, DCH removes Pn characters starting at the cursor position. Characters to the right are shifted left to fill the gap, and blank characters are inserted at the right end of the line.

ECH — Erase Character (CSI Pn X)​

Per ECMA-48 §8.3.38, ECH replaces Pn characters starting at the cursor position with blank (erased) characters. Unlike DCH, no shifting occurs — surrounding characters are not moved. The cursor position does not change.

note

The key distinction: ICH and DCH shift characters on the line (insert/delete semantics), while ECH overwrites characters in place (erase semantics).

Examples​

printf '\e[2@'       # Insert 2 blank characters at cursor
printf '\e[3P' # Delete 3 characters at cursor
printf '\e[5X' # Erase 5 characters at cursor (no shift)

Specifications​

SpecificationSection
ECMA-48—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓0.1.0Implemented via insert_blank/delete_chars/erase_chars methods
Bobcat✓0.9.0Supported via TerminalCtrl library
contour✓v0.1.0
foot✓YesICH (@) at csi.c:1116-1142, DCH (P) at csi.c:1087-1114, ECH (X) at csi.c:1158-1170
Ghostty✓v1.0.0
iTerm2✓YesVT100CSI_ICH, XTERMCC_DELCH, and ANSICSI_ECH tokens parsed and executed via terminalInsertEmptyCharsAtCursor, terminalDeleteCharactersAtCursor, and terminalEraseCharactersAfterCursor
Kitty✓YesICH/DCH/ECH (CSI @/P/X) fully implemented in vt-parser.c:1188-1247
Konsole✓YesICH (@), DCH (P), ECH (X) implemented at src/Vt102Emulation.cpp:2123,2135,2138
mintty✓YesICH (CSI @) at line 3237-3238, DCH (CSI P) at line 3239-3240, ECH (CSI X) at line 3204-3220
mlterm✓rel-2_9_0ICH at vt_parser.c:5557-5565, DCH at 5701-5708, ECH at 5753-5760
PuTTY✓0.45
Rio✓v0.0.3
rxvt-unicode✓1.2
st✓0.1
terminology✓v0.1.0
VT100✗No
VTE✓YesFully implemented in vteseq.cc as ICH/DCH/ECH handlers
WezTerm✓YesICH (InsertCharacter), DCH (DeleteCharacter), ECH (EraseCharacter) implemented as Edit::InsertCharacter/DeleteCharacter/EraseCharacter
Windows Terminal✓YesICH at ITermDispatch.hpp:54, DCH at line 55, ECH at line 100. All three character edit operations implemented.
xterm✓xterm-406
xterm.js✓2.3.0
Multiplexers
cy✓v0.1.0
GNU Screen✓v.4.2.0
tmux✓1.8ICH (CSI @), DCH (CSI P) in 1.6; ECH (CSI X) added in 1.8
tuios✓v0.0.15
Zellij✓v0.10.0ICH added in v0.10.0, DCH and ECH present since v0.1.0-alpha

See also​