Horizontal Tab (TAB)

Advance the cursor to the next tab stop on the current row.

  1. 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 never changes the pending wrap state. Nothing on the tab path clears the flag, and when the cursor is already at the right margin it does not move at all, so a pending wrap left by an earlier write survives the TAB.

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

TAB never crosses to the next row. Once the cursor reaches the right margin, further TAB characters keep it pinned there until something else moves it.

Validation

TAB V-1: Basic Advance from Column 1

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.

TAB V-2: Advance from Column 9 with No Further Stop

printf "\033[1;9H" # move to column 9
printf "\t"
printf "X"
|_________X|

The next default tab stop after column 9 is column 17, which is past the right edge of a 10 column screen, so TAB advances the cursor to column 10 instead and X is written there.

TAB V-3: Clamp at Right Margin

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.

TAB V-4: Custom Tab Stop via HTS

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____|