^[control-codes
live in libghostty-vt

Control sequences

ICH Insert Character

View as Markdown

Insert n blank cells at the cursor, shifting the rest of the line right.

CSI Pn @
Defaults
Pn = 1
ECMA-48
§8.3.64 ICH – Insert Character, p. 46
DEC STD 070
§5.11 Insert Character, p. 5-142
VT220
§4.11 Editing
VT510
ICH—Insert Character

Insert Pn blank cells at the cursor. The cursor’s cell and everything to its right moves right by Pn, and whatever is pushed past the right margin is lost. A 0 is taken as 1. The cursor does not move.

With left and right margins set, only the part of the line inside them shifts, and nothing happens at all if the cursor is outside them.

DCH is the reverse, deleting cells and pulling the rest of the line left.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.11 Editing
VT510manual, 1st ed., 1993YesICH
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMPartlyfails ICH-3 of the 3 cases that show it working
foot1.28.0, run in a VMPartlyfails ICH-3 of the 3 cases that show it working
pyte0.8.2, run as a libraryPartlyfails ICH-3 of the 3 cases that show it working
xterm.js headless6.0.0, run as a libraryPartlyfails ICH-3 of the 3 cases that show it working
alacritty_terminal0.26.0, run as a libraryPartlyfails ICH-3 of the 3 cases that show it working
ConEmubuild 230724, its documentationYesANSI escape codes
rxvt-unicode9.31, run in a VMPartlyfails ICH-3 of the 3 cases that show it working
VTE0.84.1, run as a libraryYespasses the 3 cases that show it working

Validation

ICH-1: Insert two

ABCDE
\e[1;2H
\e[2@
|A__BCD|
cursor 1,2

ICH-2: Then write into the gap

ABCDE
\e[1;2H
\e[2@
XY
|AXYBCD|

ICH-3: Inside a right margin

ABCDEF
\e[?69h   # allow left and right margins
\e[1;4s   # margins at columns 1 and 4
\e[1;2H
\e[@
|A_BCEF|
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.