Skip to main content
ansicode

CHA — Cursor horizontal absolute (column)

Move the cursor to column N of the current row (1-indexed).

Byte forms

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

\\x1b[\x1b[NG
\\033[\033[1G
\\e[\e[1G
ESC [ESC [ N G
hex1b 5b <N> 47

Description

Final byte `G` = CHA (Cursor Horizontal Absolute). Sets the column without changing the row; N defaults to 1. Commonly paired with EL (`\x1b[K`) to redraw the current line: `\x1b[1G\x1b[K` jumps to column 1 and clears to end — equivalent to `\r\x1b[K` for most CRLF terminals but cleanly avoids any line-feed semantics. HPA (`\x1b[N\``, final-byte `` ` ``) is the ECMA-48 synonym; both are widely supported.

Spec citation: ECMA-48 §8.3.9 (CHA)

Examples

bash
printf 'progress:\033[20G50%%\033[1G' 
python
print('\x1b[20G50%')
go
fmt.Print("\x1b[20G50%")
javascript
process.stdout.write('\x1b[20G50%')
c
printf("\x1b[20G50%%");

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 · 2. Cursor movement — CUU / CUD / CUF / CUB + CUP + CHA / VPA