Lugaru's Epsilon

Epsilon User's Manual and Reference
   Commands by Topic
      Getting Help
         Info Mode
         Web-based Epsilon Documentation
      Moving Around
         . . .
         Source Code Browsing Interface
      Changing Text
         Inserting and Deleting
         Killing Text
         Clipboard Access
         . . .
         Hex Mode
      . . .

Previous   Up    Next
Source Code Browsing Interface  Commands by Topic   Inserting and Deleting

Epsilon User's Manual and Reference > Commands by Topic > Moving Around >


The compare-windows command on Ctrl-F2 finds differences between the contents of the current buffer and that displayed in the next window on the screen. If called while in the last window, it compares that window with the first window. The comparison begins at point in each window. Epsilon finds the first difference between the buffers and moves the point to just before the differing characters, or to the ends of the buffers if it finds no difference. It then displays a message in the echo area reporting whether or not it found a difference.

If you invoke compare-windows again immediately after it has found a difference, the command will try to resynchronize the windows by moving forward in each window until it finds a match of at least resynch-match-chars characters. It doesn't necessarily move each window by the same amount, but instead finds a match that minimizes the movement in the window that it moves the most. It then reports the number of characters in each window it skipped past.

Normally compare-windows treats one run of space and tab characters the same as any other run, so it skips over differences in horizontal whitespace. You can set the compare-windows-ignores-space variable to change this.

The diff command also compares the buffers in two windows, but it will compare and resynchronize over and over from the beginning to the end of each buffer, producing a report that lists all differences between the two buffers. It operates line-by-line rather than character-by-character.

When resynchronizing, diff believes it has found another match when diff-match-lines lines in a row match, and gives up if it cannot find a match within diff-mismatch-lines lines. By default, diff resynchronizes when it encounters three lines in a row that match. Normally Epsilon uses a smarter algorithm that's better at finding a minimum set of differences. With this algorithm, diff-mismatch-lines isn't used. But because this algorithm becomes very slow when buffers are large, it's only used when at least one of the buffers contains fewer than diff-precise-limit bytes (by default 4 MB).

The diff command reports each difference with a summary line and then the text of the differing lines. The summary line consists of two line number ranges with a letter between them indicating the type of change: "a" indicates lines to add to the first buffer to match the second, "d" indicates lines to delete, and "c" indicates lines to change. For example, a summary line in the diff listing of "20,30c23,29" means to remove lines 20 through 30 from the first buffer and replace them with a copy of lines 23 through 29 from the second buffer. "11a12" means that adding line 12 from the second buffer right after line 11 in the first buffer would make them identical. "11,13d10" means that deleting lines 11, 12 and 13 from the first buffer (which would appear just after line 10 in the second) would make them identical.

After each summary line, diff puts the lines to which the summary refers. The diff command prefixes lines to delete from the first buffer by "<" and lines to add by ">".

The visual-diff command is like diff but uses colors to show differences. It constructs a new buffer that contains all the lines of the two buffers. Lines from the first buffer that don't appear in the second are displayed with a red background. Lines in the second buffer that don't appear in the first have a yellow background. Lines that are the same in both buffers are colored normally.

This command also does character-by-character highlighting for each group of changed lines. Instead of simply indicating that one group of lines was replaced by another, it shows which portions of the lines changed and which did not, by omitting the red or yellow background from those characters. You can set the variables diff-match-characters and diff-match-characters-limit to alter or turn off this behavior.

In a visual-diff buffer, the keys Alt-<Down> and Alt-] move to the start of the next changed or common section. The keys Alt-<Up> and Alt-[ move to the previous change or common section.

The merge-diff command is another variation on diff that's useful with buffers in C mode. It marks differences by surrounding them with #ifdef preprocessor lines, first prompting for the #ifdef variable name to use. The resulting buffer receives the mode and settings of the first of the original buffers. The marking is mechanical, and doesn't parse the text being marked off, so it may produce invalid code. For example, if an #if statement differs between the two buffers, the result will contain improperly nested #if statements like this:

#ifndef DIFFVAR
#else // DIFFVAR
#endif // DIFFVAR

Therefore, you should examine the output of merge-diff before trying to compile it.

The commands diff, visual-diff, and merge-diff all produce their output in a buffer named #diff#. With a numeric argument, they prompt instead for the destination buffer name.

The compare-to-prior-version command uses visual-diff to show the differences between the current version of a buffer and the one saved on disk. It can also compare the current version with the version prior to a certain number of editing operations. It prompts for the number of editing operations; entering zero makes it compare the current buffer to the version of it on disk. The command can display its results using merge-diff or diff instead of visual-diff; see the compare-to-prior-version-style variable.

Like compare-windows and diff, the compare-sorted-windows command compares the contents of the current buffer with that displayed in the next window on the screen. Use it when you have (for example) two lists of variable names, and you want to find out which variables appear on only one or the other list, and which appear on both. This command assumes that you sorted both the buffers. It copies all lines appearing in both buffers to a buffer named "inboth". It copies all lines that appear only in the first buffer to a buffer named "only1", and lines that appear only in the second to a buffer named "only2".

The uniq command goes through the current buffer and looks for adjacent identical lines, deleting the duplicate copies of each repeated line and leaving just one. It doesn't modify any lines that only occur once. This command behaves the same as the Unix command of the same name.

The keep-unique-lines command deletes all copies of any duplicated lines. This command acts like the Unix command "uniq -u".

The keep-duplicate-lines command deletes all lines that only occur once, and leaves one copy of each duplicated line. This command acts like the Unix command "uniq -d".

The following table shows how sample text would be modified by each of the above commands.

 Sample text  Uniq  Keep-duplicate-lines  Keep-unique-lines
 dog  dog  dog  cat
 dog  cat  horse  rabbit
 cat  horse    dog
 horse  rabbit    
 horse  dog    

Standard bindings:

  Ctrl-F2, Ctrl-X C  compare-windows
 Visual Diff only: Alt-], Alt-<Down>  next-difference
 Visual Diff only: Alt-[, Alt-<Up>  previous-difference

Previous   Up    Next
Source Code Browsing Interface  Commands by Topic   Inserting and Deleting

Lugaru Copyright (C) 1984, 2020 by Lugaru Software Ltd. All rights reserved.