Is there a way to move to the next unmatched line with in vimdiff? Not "move to the next changed line", but move to the next unmatched line for the current file.

In my case I'm trying to compare two large files, one of which should be practically a subset of the other. What I want to do is to see if there's any lines in the smaller file which are missing in the larger file. I figured I should be able to place my cursor in the larger file, and then directly jump to the next "missing" line annotation.

It just so happens that the current files in question are sorted, so I can probably use the "comm" command line utility to find the missing lines, but I was wondering if there's an easy way to do it in vimdiff, particularly if the lines aren't sorted.

  • What exactly are unmatched lines? Lines, that are added on the other buffer? Jul 22, 2016 at 18:47
  • @ChristianBrabandt Yes. Lines that are in one file (buffer) which are not in the other file (buffer).
    – R.M.
    Jul 22, 2016 at 19:15
  • and you want to move to the added lines in the other buffer? (you cannot move on top of the deleted filler lines) Jul 22, 2016 at 19:30

1 Answer 1


If I understand correctly what you want and you want to find those lines, that are unique in one buffer and therefore marked as "DiffAdd" in the other buffer.

Unfortunately, there is no native way to do it using the search() function, therefore you have to work around it with the following function, that works by searching for a line, that has the "DiffAdd" highlighting.

function! NextChange()
    while search('^.*', 'w') > 0
        if synIDattr(diff_hlID(line('.'),col('.')), 'name') is# 'DiffAdd'
com! NextChange :call NextChange()
  • Does this work for removals and changes, too?
    – Tom Hale
    Aug 3, 2016 at 4:40
  • You might need to search for 'DiffChange' highlighting as well Aug 3, 2016 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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