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

How do I jump between diff hunks in a diff view?

Answer

]c

Explanation

In diff mode, ]c jumps to the next change hunk and [c jumps to the previous one. This makes reviewing diffs efficient.

How it works

  • ]c moves to the start of the next change in a diff
  • [c moves to the start of the previous change
  • Only works when diff mode is active

Example

After opening a diff with :diffsplit other_file:

]c    " jump to next change
]c    " jump to the one after
[c    " go back one change

Tips

  • :diffget and :diffput apply or send changes at the current hunk
  • :diffupdate refreshes the diff after manual edits
  • :diffthis enables diff mode for the current buffer
  • do (diff obtain) and dp (diff put) are shortcuts for get/put

Next

How do you yank a single word into a named register?