GNU Info

Info Node: (emacs)Comparing Files

(emacs)Comparing Files


Next: Misc File Ops Prev: Directories Up: Files
Enter node , (file) or (file)node

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.

   The buffer `*diff*' has Compilation mode as its major mode, so you
can use `C-x `' to visit successive changed locations in the two source
files.  You can also move to a particular hunk of changes and type
<RET> or `C-c C-c', or click `Mouse-2' on it, to move to the
corresponding source location.  You can also use the other special
commands of Compilation mode: <SPC> and <DEL> for scrolling, and `M-p'
and `M-n' for cursor motion.  Note: Compilation.

   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.  Comparison starts at point in each
window, and each starting position is pushed on the mark ring in its
respective buffer.  Then point moves forward in each window, a character
at a time, until a mismatch between the two windows is reached.  Then
the command is finished.  For more information about windows in Emacs,
Note: Windows.

   With a numeric argument, `compare-windows' ignores changes in
whitespace.  If the variable `compare-ignore-case' is non-`nil', it
ignores differences in case as well.

   Differences between versions of files are often distributed as
"patches", which are the output from `diff' or a version control system
that uses `diff'.  `M-x diff-mode' turns on Diff mode, a major mode for
viewing and editing patches, either as "unified diffs" or "context
diffs."

   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 also Note: Emerge, and Note: Top, for convenient
facilities for merging two similar files.


automatically generated by info2www version 1.2.2.9