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

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

Answer

M

Explanation

The M command moves the cursor to the line in the middle of the current window. It stands for "Middle" and helps you quickly reposition within the visible area.

How it works

  • M places the cursor on the middle line of the window
  • The cursor moves to the first non-blank character
  • The exact line depends on the window height

Example

If your window shows lines 50-80 (31 lines), pressing M moves the cursor to approximately line 65.

Tips

  • H moves to the top of the screen
  • L moves to the bottom of the screen
  • M does not accept a count
  • Combine with zz to center the screen on the middle visible line

Next

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