Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Some of us are familiar with patch failures like "Hunk #11 FAILED at 958." -- is there a command in VIM that allows me to go to, say, 11th hunk ... without having to manually count it? Even a shortcut to go to the next patch would useful.

Is there any?

share|improve this question
up vote 1 down vote accepted

A simple method to move between patch hunks is first to search for the beginning of the patch marker

  • in a unified diff


  • in a context diff


and then to move to the next hunk by repeating the search with

n (or multiple hunks at a time, e.g. 3n)

To move backwards by hunks use

N (or e.g. 4N)

If you know all the hunk numbers you need to see, e.g. the 11th and 24th hunk, you can first use the amount prefix search Hugh suggested: 11/^@@Enter and after that move to 24th hunk either by calculating always from the top: gg24n or by direct forward advance: 13n (hunk #24 is 13 hunks ahead from the 11th).

share|improve this answer
Thanks to both Hugh and Jawa for the @@ search trick. And gg24n is something new for me, and that completes the answer to the question. – Sridhar Ratnakumar Apr 16 '10 at 17:27

Starting from the first line of a patch file in command mode*, you can go to the 11th hunk:-

  • in a context diff:


  • in a unified diff:


* and by command mode, I mean what the help calls normal mode - that is, not insert mode, and not command-line mode (:)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.