^[control-codes
live in libghostty-vt

Control sequences

CUF Cursor Forward

View as Markdown

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
VT220
§4.7 Cursor Positioning
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.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.7 Cursor Positioning
VT510manual, 1st ed., 1993YesCUF
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMPartlyfails CUF-3 of the 5 cases that show it working
foot1.28.0, run in a VMPartlyfails CUF-3 of the 5 cases that show it working
pyte0.8.2, run as a libraryPartlyfails CUF-3 of the 5 cases that show it working
xterm.js headless6.0.0, run as a libraryPartlyfails CUF-3 of the 5 cases that show it working
alacritty_terminal0.26.0, run as a libraryPartlyfails CUF-3 of the 5 cases that show it working
ConEmubuild 230724, its documentationYeslists ESC [ cols C: ANSI escape codes
rxvt-unicode9.31, run in a VMPartlyfails CUF-3 of the 5 cases that show it working
VTE0.84.1, run as a libraryYespasses the 5 cases that show it working

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|
|_____|
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.