BS Backspace
Move the cursor one column to the left.
BS
- ECMA-48
- §8.3.5 BS – Backspace, p. 34
- DEC STD 070
- §5.4.4 Back Space, p. 5-63
- VT510
- 4.2 Control Characters
Move the cursor one column to the left. Nothing is erased: the character under the cursor stays where it is until something is written over it, which is how a shell’s line editor rubs out a character, with BS, a space and another BS.
At the left margin, or the first column when there are no margins, the cursor does not move. xterm’s reverse wraparound mode (CSI ? 45 h) makes it move to the end of the previous line instead; that mode is off by default and not covered here.
If a wrap is pending, because the last thing written filled the last column, the wrap is cancelled and the cursor moves left from the last column. xterm handles BS as a one-column CursorBack, which clears it.
Validation
BS-1: Overwrite the previous character
ABC
\b
X
|ABX__|
cursor 1,4
BS-2: Nothing happens in the first column
\b\b
X
|X____|
cursor 1,2
BS-3: Rubbing out a character
ABC
\b\s\b # the line editor's erase
|AB___|
cursor 1,3
BS-4: From a pending wrap
ABCDE # fills the line; a wrap is pending
\b
X
|ABCXE|
cursor 1,5
BS-5: Stops at the left margin
\e[?69h # allow left and right margins
\e[3;5s # margins at columns 3 and 5
\e[1;3H # on the left margin
\b
X
|__X__|
libghostty-vt implements BS as a one-column CUB, and has the same difference: the cursor moves past the left margin into column 2. The VT510 manual says that at the left margin “no action occurs”, and esctest2’s test_BS_StopsAtLeftMargin expects the cursor to stay put, as xterm does.