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
- VT220
- §4.2 Control Characters
- 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.
Support
| Terminal | Version | Support | Notes |
|---|---|---|---|
| VT220 | manual, 2nd ed., 1984 | Yes | §4.2 Control Characters |
| VT510 | manual, 1st ed., 1993 | Yes | Table 4–1 |
| xterm | patch 412, xterm-411a | Yes | stops at the left margin; reverse wraparound (CSI ? 45 h) is off by default |
| libghostty-vt | 0f171f6 | Yes | BS-5: moves past the left margin |
| kitty | 0.49.1, run in a VM | Partly | fails BS-4 of the 3 cases that show it working |
| foot | 1.28.0, run in a VM | Partly | fails BS-4 of the 3 cases that show it working |
| pyte | 0.8.2, run as a library | Yes | passes the 3 cases that show it working |
| xterm.js headless | 6.0.0, run as a library | Yes | passes the 3 cases that show it working |
| alacritty_terminal | 0.26.0, run as a library | Yes | passes the 3 cases that show it working |
| rxvt-unicode | 9.31, run in a VM | Partly | fails BS-4 of the 3 cases that show it working |
| VTE | 0.84.1, run as a library | Yes | passes the 3 cases that show it working |
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.