[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
23.10 Comparing Files
The command M-x diff compares two files, displaying the
differences in an Emacs buffer named ‘*diff*’. It works by
running the diff
program, using options taken from the variable
diff-switches
. The value of diff-switches
should be a
string; the default is "-c"
to specify a context diff.
See (diff)Top section `Diff' in Comparing and Merging Files, for more
information about diff
output formats.
The command M-x diff-backup compares a specified file with its most
recent backup. If you specify the name of a backup file,
diff-backup
compares it with the source file that it is a backup
of.
The command M-x compare-windows compares the text in the current window with that in the next window. (For more information about windows in Emacs, Multiple Windows.) Comparison starts at point in each window, after pushing each initial point value on the mark ring in its respective buffer. Then it moves point forward in each window, one character at a time, until it reaches characters that don't match. Then the command exits.
If point in the two windows is followed by non-matching text when the command starts, M-x compare-windows tries heuristically to advance up to matching text in the two windows, and then exits. So if you use M-x compare-windows repeatedly, each time it either skips one matching range or finds the start of another.
With a numeric argument, compare-windows
ignores changes in
whitespace. If the variable compare-ignore-case
is
non-nil
, the comparison ignores differences in case as well.
If the variable compare-ignore-whitespace
is non-nil
,
compare-windows
normally ignores changes in whitespace, and a
prefix argument turns that off.
You can use M-x smerge-mode to turn on Smerge mode, a minor
mode for editing output from the diff3
program. This is
typically the result of a failed merge from a version control system
“update” outside VC, due to conflicting changes to a file. Smerge
mode provides commands to resolve conflicts by selecting specific
changes.
See section Merging Files with Emerge, for the Emerge facility, which provides a powerful interface for merging files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |