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

How do I jump to a specific percentage through a file, like the middle or three-quarters of the way?

Answer

50%

Explanation

Prefixing the % command with a count jumps the cursor to that percentage through the file. For example, 50% jumps to the line at the midpoint, 75% jumps three-quarters of the way down, and 1% jumps near the start. This is a fast way to navigate large files without needing to know the exact line count.

How it works

  • % without a count jumps between matching pairs (brackets, parentheses, etc.)
  • {count}% treats % differently: it calculates the line at {count} percent of the total file length and moves the cursor there
  • The result is rounded to the nearest line
  • Works with any count from 1 to 100

Example

In a file with 200 lines:

50%   → jumps to line 100
75%   → jumps to line 150
1%    → jumps to line 2
100%  → jumps to the last line (same as G)

Tips

  • 50% is a quick alternative to typing {half-of-line-count}G when you don't know the line count
  • Combine with zz to center the screen after jumping: 50%zz
  • The jump is added to the jump list, so you can return with <C-o>
  • 100% is equivalent to G (last line), and 1% goes to approximately the first line

Next

How do I configure Vim's command-line tab completion to show all matches and complete to the longest common prefix?