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

How do I jump to a specific percentage position in a file?

Answer

{N}%

Explanation

The {N}% command jumps the cursor to the line that is N percent of the way through the file. Press 50% to jump to the middle of the file, 25% to jump to the quarter mark, or 90% to jump near the end. This is one of the fastest ways to navigate large files when you have a rough idea of where your target is located.

How it works

  • {N}% calculates which line number corresponds to N percent of the total lines in the file and moves the cursor there
  • 50% jumps to the exact middle line of the file
  • 1% jumps to the first line (same as gg)
  • 100% jumps to the last line (same as G)
  • The jump is line-based — the cursor lands on the first non-blank character of the target line

Example

Given a file with 200 lines:

  50% → jumps to line 100
  25% → jumps to line 50
  75% → jumps to line 150
  10% → jumps to line 20

You're at the top of a 1000-line log file and you know the interesting part is roughly two-thirds of the way through. Press 66% and you land on approximately line 660, saving dozens of <C-d> presses or a :660 command.

Tips

  • Without a count, % jumps to the matching bracket instead — the percentage behavior only activates when you provide a number before %
  • The % jump sets a mark in the jump list, so press <C-o> to return to where you were before the jump
  • Combine with operators for large-scale edits: d50% deletes from the current line to the middle of the file, y75% yanks from the cursor to the 75% mark
  • Use {N}% as a quick way to bisect a file when searching for something — jump to 50%, decide if your target is above or below, then jump to 25% or 75%, and so on
  • The status line or ruler (:set ruler) shows your current percentage position in the file, which helps you estimate where to jump
  • For exact line jumps, use :{N} or {N}G instead — percentage jumps are for approximate, fast navigation
  • In very large files, this is significantly faster than scrolling and gives you a mental model of the file as a linear progression from 0% to 100%

Next

How do I edit multiple lines at once using multiple cursors in Vim?