Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show the difference of lines between two files

Tags:

emacs

elisp

How to implement a functionality in emacs to show the difference of contents between two files opened in two buffers? Kind of like revdiff when using mercurial.

like image 623
SFbay007 Avatar asked Dec 06 '22 06:12

SFbay007


2 Answers

Emacs has ediff, which can diff two files. To use it, just do M-x ediff, and specify the two files you want to diff.

like image 192
jh314 Avatar answered Dec 26 '22 13:12

jh314


BTW, if you want to see the differences between two blocks of text in the same buffer, you can do it as follows: - make sure smerge-mode is loaded (e.g. M-x load-library RET smerge-mode RET). - go to the beginning of the first bloc, C-SPC - go the beginning of the second bloc, C-SPC - go to the end of the second bloc, M-x smerge-makeup-conflict RET - then you can use C-c ^ R or C-c ^ = to view the differences. Note that this works better if the two blocs are pretty much consecutive.

like image 44
Stefan Avatar answered Dec 26 '22 11:12

Stefan