How do I move the cursor to the top of the visible screen?
Answer
H
Explanation
The H command moves the cursor to the first line of the currently visible screen (the "High" position). It does not scroll the viewport — it only repositions the cursor within what is already displayed.
How it works
Hmoves the cursor to the topmost line visible on the screen- The cursor lands on the first non-blank character of that line
- With a count,
3Hmoves to the 3rd line from the top of the screen
Example
If your screen currently shows lines 50–90 of a file and your cursor is on line 75, pressing H moves the cursor to line 50 (the top of the visible area). The screen does not scroll.
Tips
- Use
Mto move the cursor to the middle line of the screen - Use
Lto move the cursor to the last (bottom) line of the screen - These three commands (
H,M,L) are extremely useful for quickly repositioning within the visible area without scrolling - Combine with operators:
dHdeletes from the current line to the top of the screen - Use
ztto scroll so the current line appears at the top of the screen (different fromH, which moves the cursor instead) - The
scrolloffsetting affectsH— ifscrolloffis set to 5,Hwill move to the 6th line from the top instead of the 1st