In the p4merge tool the layout for merging 2 files look like the following.

     |               |              |
     |               |              |
     |               |              |
     |     a.txt     |  b.txt       |
     |               |              |
     |               |              |
     |               |              |
     |   Choose any change          |
     |  from a.txt or b.txt and     |
     |  finally overwrite a.txt     |
     |                              |

How to do this in emacs ?

  • Can you describe how ediff is different to that? – phils Aug 24 '18 at 5:42
  • Ediff does not show the bottom buffer. It only shows the "a.txt" and "b.txt" files buffers that can be laid out horizontally or vertically. – Talespin_Kit Aug 24 '18 at 5:44

For the side-by-side layout of windows A and B:

(setq ediff-split-window-function 'split-window-horizontally)

You may also want:

(setq ediff-window-setup-function 'ediff-setup-windows-plain)

If you're using ediff for a merge you'll get the third/bottom window C showing the chosen result. This would happen automatically if the merge is being triggered by a version control operation, but you can use the M-x ediff-merge command to do so manually.

Note that in the manual case I think you'll also need to manually select the filename to write buffer C to (using the key sequence w c). You can probably use the minibuffer history to select the filename with M-p or <up>.

  • Thanks. Exactly what i wanted to do. Does the hardcore emacs users use anyother mere package other that ediff. Just to make sure using the right tool. – Talespin_Kit Aug 24 '18 at 6:19
  • 1
    smerge is the other popular option (also built-in). It's fairly different in use to ediff (and I expect you'll like ediff better), but some people do prefer its approach. They're both solid options, so AFAIK nobody has bothered to try to implement other alternatives. – phils Aug 24 '18 at 11:31

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.