Navigating around the screen

4.4
(42)

Vim has numerous key mappings for moving around the screen. Some of these you might not know about or might not be a part of your regular muscle memory.

The following mappings all move the cursor around the screen without shifting the viewport. That is, the lines stay in place, but the cursor moves. These are really useful for moving through text such as prose, markdown, READMEs, etc. In those types of files you don’t have method/function navigation.

  • H – Move cursor to the first line on the screen (mnemonic: “High”)
  • M – Move cursor to the middle line on the screen (mnemonic: “Middle”)
  • L – Move cursor to the last line on the screen (mnemonic: “Low”)

The next set move the viewport — the cursor stays where it’s at, but the lines behind it move. Generally these are useful for getting a better view of the surrounding text or jumping quickly through a document when you don’t know what you’re looking for.

  • <ctrl-f> – Move viewport forward one full screen (mnemonic: “Forward”)
  • <ctrl-b> – Move viewport backwards one full screen (mnemonic: “Backward”)
  • <ctrl-d> – Move viewport down one half screen (mnemonic: “Down”)
  • <ctrl-u> – Move viewport up one half screen (mnemonic: “Up”)

Related, check out two other tips we’ve written about before:

How useful was this tip?

Average rating 4.4 / 5. Vote count: 42

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts