Center current line in Vim with zz

Part of my guide of vim tips/snippets

Controlling position of cursor on screen with zz

Using zz to centre current line in your screen

  • Pressing zz (lowercase) in vim will center the cursor/current line on the screen.
  • Useful if you are near the bottom or top of the screen and want to see lines higher/lower, without changing what line you’re still on.
  • Note: you can also use the :set scrolloff=5 to always ensure your current line is 5 lines from the top/bottom of screen.

Using ZZ (uppercase) to save and exit the file

  • Pressing ZZ (shift + zz) will save & exit the file
Part of my guide of vim tips/snippets