Skip to main content
ansicode

CBT — Cursor Backward Tabulation (CSI Z)

Move the cursor back N tab stops — the reverse of pressing Tab.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[NZ
\\033[\033[1Z
\\e[\e[1Z
ESC [ESC [ N Z
hex1b 5b <N> 5a

Description

Cursor Backward Tabulation. Final byte `Z` (0x5a) moves the cursor backward to the previous tab stop, repeated N times (default 1 if the parameter is omitted). It is the mirror of CHT (`CSI Ps I`) and the moral opposite of pressing the Tab key (HT, 0x09). If the cursor is already at column 1 or before the first remaining tab stop, it stays put. Default tab stops live every 8 columns unless the application has cleared or shifted them with TBC (`\x1b[Ng`) and HTS (`\x1bH`). CBT is rarely emitted by humans, but matters for terminfo capability `cbt` and for any TUI replaying recorded keystrokes (Shift-Tab in form fields, etc.).

Spec citation: ECMA-48 §8.3.7 (CBT)

Examples

bash
printf 'a\tb\tc\033[2Z|'   # cursor jumps back 2 tab stops, then writes |
python
import sys; sys.stdout.write('\x1b[2Z')
go
fmt.Print("\x1b[2Z")
javascript
process.stdout.write('\x1b[2Z')
c
printf("\x1b[2Z");

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

Related sequences