Pauli's software ->Vedit resources -> Compare Tools 26. 08. 2012  

Compare Tools

Compare files and directories with VEDIT text editor

This free toolset contains Vedit macros for comparing files and directories. The package contains the following files:

cmp_1_2.vdm - All new file compare macro
compdir.vdm - Enhanced version of the directory compare macro that comes with Vedit
doubleclick_cmpdir.vdm - Double-click macro for compdir.vdm
cmp_1_2.chm - Help file for both of the above

Click the link below to download the package.

Download Download   -   V2.1   -   26.08.2012   -   71 K   -   Vedit 6.1 or 6.2


To install the package, just un-zip the files to your user-mac directory. You can move the file CMP_1_2.CHM to Vedit help directory if you like.


Descriptions of the files in CMP10.ZIP:



Screenshot of VEDIT running CMP_1_2.VDM

Cmp_1_2.vdm is a file compare tool designed to replace the compare.vdm macro - and perhaps even the { Search → Compare buffers } function. Cmp_1_2.vdm can compare any two buffers and start comparison from any position within the buffers, or even compare two locations of the same buffer. It can compare in both forward and backward direction and perform automatic resynchronization.

Specifying the files (buffers) to be compared is easy:

  1. Go to first buffer to be compared and move cursor to the position where to start comparing.
    Load/execute cmp_1_2.vdm (or select "Set 1st position for compare" from your tools menu).
    Your Tools menu is now replaced with a special cmpTools menu and shortcut keys are defined for the menu items.
  2. Go to 2nd buffer to be compared and move cursor to the position where to start comparing.
    Then select "Compare" from the cmpTools menu or press the hot-key <Shift-F7>.

Comparing starts immediately, and the cursor on each buffer is moved to the first location where the files differ. Optionally, the screen is split vertically or horizontally to show both files.

You only need to specify the buffers once. After that, just execute the "Compare" command again, and comparison continues from current cursor location on each buffer. Before that, you can freely move the cursor and perform almost any edit operations, even run other macros (with some limitations). You can use F12 to toggle between the two buffers.

Re-Sync command in the cmpTools menu (Shift-F8) automatically detects the location where the files match again. No need to manually find the matching location any more! To find next difference, just execute "re-Sync", and then "Compare" again.

You can compare and re-sync in reverse direction by selecting "compare Reverse" and "re-sync reverse" (Shift-F6 and Shift-F5), respectively.

Optionally, the macro can highlight the difference by setting block markers. When this option is selected, executing "Compare" first executes the compare operation. The macro then sets Block Begin marker at this location on each buffer. Then re-sync operation is immediately executed to find where the files match again. Bock End markers are set to that location on each buffer. This way it is easy to see which part of text is different. When this option is enabled, you do not need to execute the re-sync command. Just execute "Compare" and/or "compare Reverse" repeatedly to jump forward and backward from difference to difference.

Optionally, the highlighted block in "left" buffer is copied to Scratchpad. After executing compare, the "right" buffer is active, so you can copy the difference there simply by doing "paste Scratchpad". This is a handy way to selectively merge changes from "left" file to "right" file.

Alternatively, you can perform semi-automatic synchronization. Move cursor on either buffer anywhere on a line you expect to match and select "find Matching line" (Shift-F11). The closest full line in the other buffer that matches this line in forward or backward direction is located (using z-search) and windows are aligned at this line. If a block is highlighted, only the highlighted text is searched. This allows matching part of a line or multiple lines.

The options can be selected from Options dialog, which is opened by selecting "Options" from the cmpTools menu. In addition to the options mentioned above, you can choose to ignore case, ignore space change, and ignore empty lines.

Click the [Advanced] button on Options dialog to open Advanced Options dialog. Here you can adjust the parameters used for re-synchronization, and set the number of columns to be ignored at the begin of line (e.g. for skipping time stamp on log files). The options are saved in the file compare.ini.

Select "Help" from cmpTools menu or press Shift-F1 to open the help-file.

To exit the compare mode, select "Exit compare" from cmpTools menu or press <Shift-F9>. Your original Tools menu and keyboard configurations are restored.



Main dialog of compdir.vdm

Compdir.vdm is enhanced version of the directory compare macro that comes with Vedit. Since the filename is the same, you can put this macro in your user-mac directory and it is automatically used instead of the original. You can still run the original macro from the macros directory with { Tools → Load/execute macro }.

This version of the macro uses cmp_1_2.vdm to compare individual files, instead of compare.vdm. In addition, it contains several enhancements.

Instead of wizard-style interface, all the basic settings can now be set in single dialog box. With this dialog you can select the two directories to be compared and the basic options. The previously used directories and settings are remembered, so next time you want to run the same comparison you only need to click [OK] or press Enter. Optionally, the directories can be configured to default to current files directory.

You can select the directories either by typing them in the input boxes, or interactively by clicking on the [Browse] buttons.

Options can be set using Options dialog (click the [Options] button), instead of editing the macro code. They are saved in file compare.ini.

To exclude some files from being compared, you can add Exclude Filters by clicking the [Filters] button.

The results of the directory comparison are displayed in 4 windows, as before. However, the sizes of the windows are automatically adjusted depending on how many files are listed in each window. In the different files window, you have option to display the files in dir1 and dir2 either on separate lines (as before), or on a single line in different columns. The file that is newer is marked with '*'. Cursor line is highlighted.

Your Tools menu is replaced with special Tools menu and keyboard shortcuts are defined for it. The menu contains functions for copying, moving, renaming and deleting files. In addition, you can set Options and Filters, re-run the directory comparison, and view Help.

To compare individual files, move cursor to the line contining the filename and press F12 (or select "Compare files" from the Tools menu). A new instance of Vedit opens and cmp_1_2.vdm is called to compare the files. This works both in Different files and Same files window. If you press F12 while in one of the Unique files windows, another instance of Vedit just opens to edit that file.


Double-click macro

Doubleclick_cmpdir.vdm is a simple double-click macro for compdir.vdm. It is called from double-click event macro and it just calls compdir.vdm (which must be already loaded in memory).

You can double-click on a file in any of the file list windows to compare or view the file(s) (same as pressing F12). This requires Vedit 6.2 or later.


The Help file

Cmp_1_2.chm is the help file for both cmp_1_2.vdm and compdir.vdm. It is in HTML-Help format. You can call the help file either from the macro, or by double-clicking on it in a Windows Explorer window.

The file must me located either in the USER_MACRO directory (typically \vedit\user-mac) or in the help directory under Vedit home direcory (\vedit\help).

Revision history

V2.1   2012.08.26

V2.0   2012-07-15