During a magit-rebase I'm running into conflicts on single long lines, where I'd like to take some parts of the line from the A and some from the B buffer.

After hitting * -refine current region within magit-ediff-dwim I can view the wordwise diff between two buffers. However, the actual diff chunks to choose from are much bigger. Is it possible to update these chunks so I can resolve the conflicts word by word (similar to ediff-regions-wordwise)?

1 Answer 1


Good question. This feels like it should be standard. With a little digging into the code and experimenting, this seems at first glance to work:

From the ediff control window:

  • M-: (setq ediff-word-mode t) RET
  • ! to run ediff-update-diffs

Which we can encapsulate in a command (which I've bound to . in the ediff control buffer) like so:

(defun my-ediff-toggle-word-mode ()
  "Toggle between linewise and wordwise comparisons."
  (setq ediff-word-mode (not ediff-word-mode))

(add-hook 'ediff-startup-hook #'my-ediff-startup-hook)

(defun my-ediff-startup-hook ()
  "Custom `ediff-startup-hook' behaviours."
  (define-key ediff-mode-map (kbd ".") #'my-ediff-toggle-word-mode))

Note that ediff-word-mode disables refinements, so you would need to use @ to restore that (if desired) after toggling back to linewise diffs.

If you don't experience any issues with this (let me know), then I think this should be a feature-request (M-x report-emacs-bug).

  • This works exactly as expected, thank you very much! I agree that it would be useful to have this included in ediff (including a description of the keybinding in the ediff control panel).
    – lab
    Jul 15, 2019 at 13:33
  • I suspect it should either be an additional state for @ to cycle through, or else that C-u @ should be used, as it feels like a part of the refinement functionality.
    – phils
    Jul 15, 2019 at 22:17

Your Answer

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

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