CUF Cursor Forward
Move the cursor right n columns.
CSI Pn C
- Defaults
- Pn = 1
- ECMA-48
- §8.3.20 CUF – Cursor Right, p. 36
- DEC STD 070
- §5.4.4 Cursor Forward, p. 5-45
- VT510
- CUF—Cursor Forward
Move the cursor Pn columns to the right. A 0 is taken as 1. The cells passed over are left as they are.
The cursor stops at the right margin if it started at or left of it, and at the last column if it started right of the right margin. It never wraps onto the next line and never scrolls.
Moving the cursor cancels any pending wrap. DEC STD 070 calls the pending wrap the Last Column Flag, and its appendix on autowrap lists this among the controls that should reset it (§D.6.1, p. D-13); xterm clears it in CursorForward, and libghostty-vt does the same. A cursor in the last column with a wrap pending stays in that column, and the next character overwrites the last cell rather than starting a new line.
CUB goes the other way.
Validation
CUF-1: Right n columns, leaving the cells alone
ABCDE
\r
\e[2C
X
|ABXDE|
CUF-2: Stops at the last column
\e[99C
X
|____X|
|_____|
CUF-3: Stops at the right margin
\e[?69h # allow left and right margins
\e[2;4s # margins at columns 2 and 4
\e[1;3H
\e[9C
X
|___X_|
CUF-4: Right of the right margin
\e[?69h # allow left and right margins
\e[1;3s # margins at columns 1 and 3
\e[1;4H # right of them
\e[9C
X
|____X|
CUF-5: From a pending wrap
ABCDE # fills the line; a wrap is pending
\e[C
X
|ABCDX|
|_____|