DCH Delete Character
Delete n characters at the cursor, pulling the rest of the line left.
CSI Pn P
- Defaults
- Pn = 1
- ECMA-48
- §8.3.26 DCH – Delete Character, p. 38
- DEC STD 070
- §5.11 Delete Character, p. 5-144
- VT510
- DCH—Delete Character
Delete Pn characters, starting with the one under the cursor. The rest of the line, up to the right margin, moves left to close the gap, and blank cells appear at the right margin. A 0 is taken as 1, and asking for more characters than there are between the cursor and the right margin deletes only those. The cursor does not move.
Only the cursor’s line is affected, and only the part of it between the left and right margins. If the cursor is outside those margins, DCH does nothing. The top and bottom margins do not matter: DCH works on any line. Character attributes move with the characters, and the VT510 manual says the blanks added at the right margin have none. Insert/replace mode makes no difference.
ICH is the reverse. ECH blanks characters without moving the rest of the line.
Validation
DCH-1: Delete one character
ABCDE
\e[1;2H
\e[P
|ACDE__|
cursor 1,2
DCH-2: Delete two
ABCDE
\e[1;2H
\e[2P
|ADE___|
DCH-3: More characters than there are
ABCDE
\e[1;2H
\e[99P
|A_____|
DCH-4: Inside left and right margins
abcde
\e[?69h # allow left and right margins
\e[2;4s # margins at columns 2 and 4
\e[1;3H
\e[P
|abd_e|
DCH-5: Nothing happens outside the margins
abcde
\e[?69h # allow left and right margins
\e[2;4s # margins at columns 2 and 4
\e[1;1H # left of them
\e[99P
|abcde|