Horizontal Tab (TAB)
Advance the cursor to the next tab stop on the current row.
- 0x09
- TAB
Hex: 0x09. ASCII: ^I (Ctrl+I).
Advance the cursor to the next tab stop on the current row. The default tab stops are every 8 columns, so a fresh terminal has stops at columns 9, 17, 25, and so on. If no further tab stop exists before the right margin, the cursor stops at the right margin (or last column when no right margin is set).
TAB does not erase or rewrite the cells between the previous cursor
position and the new one. Existing content under the path of the tab is
preserved; the cursor simply jumps forward.
This sequence always unsets the pending wrap state.
Tab stops are configurable. Use HTS to set a tab stop at the current column and TBC to clear stops. For multi-stop advances, see CHT (forward) and CBT (backward).
Note
TABnever crosses to the next row. Once the cursor reaches the right margin, furtherTABcharacters keep it pinned there until something else moves it.
printf "\033[1;1H" # move to top-left
printf "\t"
printf "X"
|________Xc|
The cursor advances from column 1 to column 9 (the first default tab stop),
and X is written there.
printf "\033[1;9H" # move to column 9
printf "\t"
printf "X"
|________________X_|
From column 9, TAB advances to column 17.
cols=$(tput cols)
printf "\033[1;${cols}H" # move to last column
printf "\t"
printf "X"
|_________X|
With no further tab stop available, the cursor stays at the right margin and the next write lands there.
printf "\033[1;1H" # move to top-left
printf "\033[3g" # clear all tab stops
printf "\033[1;5H" # move to column 5
printf "\033H" # HTS: set tab stop here
printf "\033[1;1H" # back to column 1
printf "\t"
printf "X"
|____Xc____|