Next: , Previous: , Up: Files   [Contents][Index]


14.8 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, whose value should be a string.

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 C-c C-c to find 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. See 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. Point moves forward in each window, a character at a time in each window, until the next characters in the two windows are different. Then the command is finished. For more information about windows in Emacs, 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.