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
:diffthisactive;]nfinds raw<<<<<<<markers too - Combine with
ddand editing commands to quickly delete the unwanted half of a conflict - Use
:diffgetand:diffputwhen 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/[nstill work to navigate