[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

N.9 Comparar archivos

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. @xref{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, @ref{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 Merging Files with Emerge, and (ediff)Top section `Top' in The Ediff Manual, for convenient facilities for merging two similar files.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Roberto on enero, 3 2007 using texi2html 1.76.