CUU / CUD / CUF / CUB — Move cursor
Move the cursor up / down / right / left by N cells.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\\x1b[
\x1b[NA (up; B down, C right, D left)\\033[
\033[1A\\e[
\e[1AESC [
ESC [ N Ahex
1b 5b <N> 41Description
Final byte determines direction: `A`=up (CUU), `B`=down (CUD), `C`=forward/right (CUF), `D`=back/left (CUB). N defaults to 1 if omitted (`\x1b[A` moves up one line). The cursor stops at the edge of the visible region; it does NOT wrap.
Spec citation: ECMA-48 §8.3.22 (CUU) / §8.3.19 (CUD) / §8.3.20 (CUF) / §8.3.18 (CUB)
Parameters
| A | up by N |
| B | down by N |
| C | right by N |
| D | left by N |
Examples
printf 'line1\nline2\033[1A\rCHANGED\033[1B\r\n'import sys; sys.stdout.write('\x1b[2A')fmt.Print("\x1b[2A")process.stdout.write('\x1b[2A')printf("\x1b[2A");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
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | no | no |
Related sequences
In the family cookbook
CSI cookbook · 2. Cursor movement — CUU / CUD / CUF / CUB + CUP + CHA / VPA