Skip to main content
ansicode

CUP — Set cursor position

Move the cursor to absolute row/column (1-indexed).

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[row;colH
\\033[\033[1;1H
\\e[\e[1;1H
ESC [ESC [ row ; col H
hex1b 5b ... 48

Description

Both `H` (CUP) and `f` (HVP) are synonyms — same behavior. Row and column are 1-based; omitting both defaults to (1,1), i.e. the top-left of the screen or scrolling region. Out-of-range values are clamped to the visible region.

Spec citation: ECMA-48 §8.3.21 (CUP)

Examples

bash
printf '\033[2;5HHello at (2,5)\n'
python
print('\x1b[2;5HHello at (2,5)')
go
fmt.Print("\x1b[2;5HHello at (2,5)\n")
javascript
process.stdout.write('\x1b[2;5HHello at (2,5)\n')
c
printf("\x1b[2;5HHello at (2,5)\n");

Terminal support

xterm
yes
Linux console (fbcon)
yes
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
yes
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences

In the family cookbook

CSI cookbook · 1. The envelope — `\x1b[` … `<final-byte>`