ICH — Insert Character (CSI Pn @)
Shift the rest of the current line right by N cells and blank-fill the gap — the primitive vim's insert mode is built on.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[Pn@\033[Pn@\e[Pn@ESC [ Pn @1b 5b <Pn> 40Description
Insert Character. Final byte `@` (0x40) shifts the cursor position and every cell to its right within the current line rightward by `Pn` cells (default 1); cells that fall off the right edge are discarded and the `Pn`-wide gap at the cursor is filled with blanks (SP, 0x20) carrying the current SGR background. The cursor itself does not move. ICH is the primitive `vim` insert mode emits per typed character — `vim` could redraw the whole line for every keystroke, but using ICH keeps screen updates O(1) per character. Pair with DCH (`\x1b[Pn P`) to delete the same way. ICH is bounded by the right margin (DECSTBM column-margins, if set); cells past the right margin are NOT shifted into. The terminfo capability is `ich1` (Pn=1) or `ich` (parameterised).
Spec citation: ECMA-48 §8.3.64 (ICH)
Examples
# Move cursor to column 5, insert 3 cells, then type 'xyz' (it lands at col 5).\nprintf 'Hello world\033[5G\033[3@xyz'import sys; sys.stdout.write('\x1b[3@') # open a 3-cell gap at the cursorfmt.Print("\x1b[3@")process.stdout.write('\x1b[3@')printf("\x1b[3@");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