CHT/CBT
AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard
CHT (Cursor Forward Tabulation) and CBT (Cursor Backward Tabulation) are CSI sequences that move the cursor forward or backward by a specified number of tab stops.
Syntax
CSI Pn I CHT — Cursor Forward Tabulation
CSI Pn Z CBT — Cursor Backward Tabulation
Formal syntax
CHT = 0x1b, "[", [ Pn ], "I" ;
CBT = 0x1b, "[", [ Pn ], "Z" ;
Pn = digit, { digit } ; (* default: 1 *)
digit = "0" | "1" | "2" | "3" | "4"
| "5" | "6" | "7" | "8" | "9" ;Parameters
| Parameter | Description | Default |
|---|---|---|
Pn | Number of tab stops to advance/retreat | 1 |
Description
Per ECMA-48 §8.3.10 (CHT) and §8.3.7 (CBT):
- CHT (
CSI Pn I) — Moves the cursor to thePn-th following tab stop. This is equivalent to pressing HT (0x09)Pntimes, but expressed as a single sequence. - CBT (
CSI Pn Z) — Moves the cursor to thePn-th preceding tab stop.
Tab stops are set by HTS and cleared by TBC. The default tab stops are at every 8th column (1, 9, 17, 25, ...).
If there are fewer remaining tab stops than requested, the cursor moves to the last (or first, for CBT) column of the line.
Examples
printf '\e[2I' # Move forward 2 tab stops
printf '\e[Z' # Move backward 1 tab stop
Specifications
| Specification | Section |
|---|---|
| ECMA-48 | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | 0.15.0 | CHT added in 0.15.0, CBT existed earlier (bug fix in 0.7.0) |
| Bobcat | ✓ | 0.9.0 | Supported via TerminalCtrl library |
| contour | ✓ | v0.1.0 | |
| foot | ✓ | Yes | CHT (I) at csi.c:1172-1189, CBT (Z) at csi.c:1191-1204 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | Yes | VT100CSI_CHT and ANSICSI_CBT tokens parsed and executed via terminalAppendTabAtCursor and terminalBackTab |
| Kitty | ✓ | Yes | CHT/CBT (CSI I/Z) fully implemented in vt-parser.c:1213-1216 |
| Konsole | ✓ | Yes | CHT (I), CBT (Z) implemented at src/Vt102Emulation.cpp:2132,2139 |
| mintty | ✓ | Yes | CHT (CSI I) at line 3179-3181, CBT (CSI Z) at line 3465-3473 |
| mlterm | ✓ | rel-2_9_0 | Implemented at vt_parser.c:5639-5772 |
| PuTTY | ~ | 0.45 | CBT (CSI Z) supported, CHT (CSI I) not implemented |
| Rio | ✓ | v0.0.3 | |
| rxvt-unicode | ✓ | 1.2 | |
| st | ✓ | 0.1 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | Fully implemented in vteseq.cc as CHT/CBT handlers |
| WezTerm | ✓ | Yes | CHT (ForwardTabulation) and CBT (BackwardTabulation) implemented as Cursor::ForwardTabulation and Cursor::BackwardTabulation |
| Windows Terminal | ✓ | Yes | Implemented in ITermDispatch.hpp:85-86 as ForwardTab (CHT) and BackwardsTab (CBT) |
| xterm | ✓ | xterm-406 | |
| xterm.js | ✓ | 2.3.0 | |
| Multiplexers | |||
| cy | ✓ | v0.1.0 | |
| GNU Screen | ✓ | v.4.2.0 | |
| tmux | ✓ | 1.6 | CHT not found in code; CBT (CSI Z) implemented |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.9.0 | |
See also
- HT — Horizontal Tab — Single tab stop advance
- HTS — Set Tab Stop — Set a tab stop at the current column
- TBC — Tabulation Clear — Clear tab stops