Tags

, ,

While working on a file opened using vim I often want to see the line where the cursor is at in the center or at the top (and sometime at the bottom) by scrolling up or down — and I often forget how to do that without using j, k or other cursor movement commands. Here’s how to do it:

  • z. [z followed by a dot (.)] — to put the line with the cursor at the center,
  • zt — to put the line with the cursor at the top
  • zb — to put the line with the cursor at the bottom of the screen.

NOTE: A somewhat related  trick is to move your cursor to the top, middle or bottom of the screen without scrolling the page using H (i.e., shift+h), M and L, respectively.

Advertisements