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

How do I move the cursor to the middle or bottom of the visible screen?

Answer

M to move to the middle, L to move to the bottom

Explanation

How it works

Vim offers three commands to jump the cursor to specific vertical positions on the visible screen without scrolling:

  • H moves to the top of the screen (High).
  • M moves to the middle of the screen (Middle).
  • L moves to the bottom of the screen (Low).

These commands are extremely useful when you can see the area you want to edit on screen but it is far from your cursor. Rather than pressing j or k repeatedly, a single keystroke places you in the right zone.

The cursor lands on the first non-blank character of the target line. If scrolloff is set, H and L will respect the offset and not jump to the very first or last visible line.

L also accepts a count: 3L moves to the third line from the bottom of the screen, just as 3H moves to the third line from the top.

Example

Imagine you have a long file and can see a function definition near the bottom of your terminal window:

  1. Press L to jump the cursor to the last visible line.
  2. Press M to jump to the middle of the screen if the target is roughly centered.
  3. Combine with operators: dL deletes from the current line to the bottom of the screen, and yM yanks from the current line to the middle.

These three screen-position commands pair well with zz, zt, and zb which scroll the screen relative to the cursor, letting you quickly orient both the viewport and your cursor position.

Next

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