vimtricks.wiki Concise Vim tricks, one at a time.

How do I scroll so the current line is at the bottom of the screen?

Answer

zb

Explanation

The zb command redraws the screen with the current line at the bottom of the window. This is useful when you want to see context above the current line.

How it works

  • zb positions the current line at the bottom edge of the window
  • The cursor stays on the same line and column
  • The screen shifts to show content above the current line

Example

If the cursor is on line 50 and the screen shows lines 30-60, pressing zb redraws so the screen shows approximately lines 20-50.

Tips

  • zt positions the line at the top
  • zz positions it in the center
  • z- positions at bottom and moves cursor to first non-blank
  • Useful after jumping to a definition to see the code leading up to it

Next

How do you yank a single word into a named register?