Reposition the current line

Expose the area of the file surrounding your cursor with these z commands

You will often find yourself navigating a file that doesn’t entirely fit within your window’s viewport. The smaller your monitor and the larger your file, the more likely this will occur. In these cases, it might more comfortable to have the viewport shifted, moving the current line. With some quick key presses in normal mode, you can move your current line to the top, middle, or bottom of the screen as easy as so:

  • zt repositions the viewport so the current line is at the top, with one extra space above. (Just remember t for t op.)

  • zz repositions the viewport so the current line is in the middle.

  • zb repositions the viewport so the current line is at the bottom, with one extra space below. (Just remember b for b ottom.)

Here’s a quick screencast showing these in use:

First we move the current line to the top of the window with zt, then to the middle, with zz, then lastly to the bottom with zb. You can see how repositioning can be helpful to quickly expose portions above or below your working line.


Was this useful? Help us improve!

With your feedback, we can improve VimTricks. Click a link to vote: