When I am resolving merge conflicts with Magit and Smerge, is there a way for me to cycle through all merge conflicts in the project? Currently I can only move through them one file at a time.

I wrote something like this as as utility but it's not great:

(defun jump-to-first-merge-conflict ()
  (execute-kbd-macro (kbd "<return>")))

It would be nice if I could just use smerge in a project context, instead of a file context.


Just 7 hours ago to Smerge was added a new command to do exactly that. Now you can use M-x smerge-vc-next-conflict to either jump to the next conflict in focused buffer or to the next conflicted file in the repository that the file belongs to.

Don't forget to use (require 'smerge-mode) for this function to appear.

For those who can't for some reason upgrade Emacs, I can share an analogous function next-conflict I've been using:

(require 'vc)

(defun smerge-next-safe ()
    "returns t on success, nil otherwise"
  (condition-case err
      (not (smerge-next))

(defun next-conflict ()
  (let ((buffer (current-buffer)))
    (when (not (smerge-next-safe))
      (if (eq buffer (current-buffer))
          (message "No conflicts found")
        (goto-char 0)
| improve this answer | |
  • 1
    thank you, that's all I needed! – elmarco Aug 1 '19 at 7:40
  • I am having Symbol’s function definition is void: vc-find-conflicted-file error – alper Aug 27 at 19:53
  • @alper try evaluating (require 'vc) to see if that helps. But worth noting that this is odd, because for me it's available even if I run emacs -Q to not load any configs. What Emacs version you have? – Hi-Angel Aug 28 at 6:39
  • 1
    I am using Emacs 26.3, seems like (require 'vc) fixed the issue – alper Aug 28 at 11:13

Magit does not support that currently, but I have just added a note to a related feature request.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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