Vertical Position Absolute (VPA)
Move the cursor to a specific row without changing the column.
- 0x1B
- ESC
- 0x5B
- [
- ____
- y
- 0x64
- d
The parameter y must be an integer greater than or equal to 1. If y is
less than or equal to 0, adjust y to be 1. If y is omitted, y
defaults to 1. The row value is one-based: the topmost row is row 1.
This sequence always unsets the pending wrap state.
VPA is functionally equivalent to Cursor Position (CUP)
with the column set to the current cursor column and the row set to y.
The cursor column does not change as a direct effect of VPA, but origin
mode may still influence the resulting position (see below).
If origin mode is NOT set, the cursor is moved to row y
clamped to the bottom row of the screen.
If origin mode is set, y = 1 corresponds to the
top margin and the maximum value for y is the
bottom margin. When origin mode is set, it is impossible to
position the cursor outside the vertical scroll region with this sequence.
Tip
VPA is the vertical counterpart to HPA. If you need to set both the row and the column at once, use CUP instead.
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[1;3H" # move to row 1, column 3
printf "A"
printf "\033[3d" # VPA to row 3 (column 4 retained)
printf "X"
|__A_______|
|__________|
|___Xc_____|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[500d" # VPA past the bottom edge
printf "X"
|__________|
|__________|
|Xc________|
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[2;3r" # scroll region rows 2..3
printf "\033[?6h" # origin mode
printf "\033[1;1H" # origin-relative top-left
printf "\033[500d" # VPA past the bottom margin
printf "X"
|__________|
|__________|
|Xc________|
cols=$(tput cols)
printf "\033[${cols}G" # move to last column
printf "A" # set pending wrap state
printf "\033[1d" # VPA cancels pending wrap
printf "X"
|________AX|