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

How do I jump between merge conflict markers in a file?

Answer

]n

Explanation

During a git merge, Vim can navigate directly between conflict markers (<<<<<<<, =======, >>>>>>>) using ]n and [n. This lets you move through every conflict in the file without searching manually, making conflict resolution faster and less error-prone.

How it works

  • ]n — jump forward to the next conflict marker or diff hunk
  • [n — jump backward to the previous conflict marker or diff hunk

These motions work in both diff mode (:diffthis) and in files containing raw merge conflict markers left by git merge.

Example

After a merge with conflicts, your file might contain:

function greet() {
<<<<<<< HEAD
  return 'Hello';
=======
  return 'Hi';
>>>>>>> feature-branch
}

Press ]n to jump to the next <<<<<<< marker, resolve the conflict, then press ]n again to jump to the next one. Press [n to go back if you overshoot.

Tips

  • Works independently of diff mode — you don't need :diffthis active; ]n finds raw <<<<<<< markers too
  • Combine with dd and editing commands to quickly delete the unwanted half of a conflict
  • Use :diffget and :diffput when in Vimdiff mode for a more structured merge workflow
  • In Neovim, plugins like vim-fugitive's :Gvdiffsplit! provide a 3-way merge interface, but ]n/[n still work to navigate

Next

How do I see a summary of all previous quickfix lists from my current session and navigate between them?