Centering the Cursor

zz, zt, zb โ€” move the viewport, not the cursor.

Keys: zz, zt, zb

zz centers the cursor's line on screen. zt scrolls so the cursor's line is at the top. zb scrolls so the cursor's line is at the bottom.

After a search jump or function navigation, the cursor often ends up at the top or bottom edge of the visible window โ€” too little context. Three commands fix that without moving the cursor: zz, zt, zb.

Center cursor's line on screen
KeyNote
z
z
Scroll cursor's line to top
KeyNote
z
t
Scroll cursor's line to bottom
KeyNote
z
b
zz โ€” center the cursor
zz revisited
zt โ€” cursor to top
zb โ€” cursor to bottom

Reference

Key Action
zz Cursor's line โ†’ middle of screen
zt Cursor's line โ†’ top of screen
zb Cursor's line โ†’ bottom of screen

Worked example โ€” zz

Bring the current line to the center.

Step 1 ยท Cursor near the bottom of the visible viewport.
Cursor near the bottom of the visible viewport.
Step 2 ยท zz ยท zz โ€” line moved to center, screen scrolled.
zz โ€” line moved to center, screen scrolled.

zt puts the line at the top; zb at the bottom. The cursor doesn't move in the buffer โ€” only the viewport.

โ–ถ Try this in the simulator

See also: {key:z.} / {key:z+} / {key:z-} โ€” Scroll and Land on First Non-Blank, Screen Position Jumps, {key:z}{n}{key:Enter} โ€” Set Window Height