No announcement yet.

Getting Beyond Compare to Match Similar Lines as Desired

  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Beyond Compare to Match Similar Lines as Desired

    I am using Beyond Compare 4.1.6 to diff text configuration files. There is one configuration parameter per line, and each line is formatted as follows: :=

    I would like to configure Beyond Compare such that it will align only lines when the : portion of the line is exactly the same in both files. Put differently, everything from the beginning of the line up to and including the colon must match exactly for the two lines to be aligned. Note that a colon cannot occur in , so the colon I want Beyond Compare to base its alignment decision on will always be the first colon in the line.

    An example is:

    # FILE 1

    # FILE 2

    Beyond Compare aligns these two lines even though I don't want it to.

    I've been unable to coerce Beyond Compare to compare lines as desired by editing its grammar rules or by tweaking other features.

    How may I get Beyond Compare to match lines as described above?

    Thank you!

  • #2

    In the Text Compare, you can define a grammar which matches on that specific Regular Expression. For the beginning of the line to the first colon, you could use:

    This is defined in the File Format. Create a new format in the Tools menu -> File Formats dialog; New + Text Format. In the grammar tab, define this Basic Reg Expression and give it a custom name.
    If your files have a unique extension, binding the format to that extension type in the first tab is useful, too.

    In the Text Compare, you can then go to the Session menu -> Session Settings, and mark that new element as Important (checked) and "Everything Else" as Unimportant. In the Alignment tab, set to Never Align Differences.

    Now your files will only align if the important (custom grammar element) text is equal, and everything else is unimportant. Unimportant differences are still differences as long as they are blue. If you enable the Ignore Unimportant Differences toggle, then they'll be ignored and set to black text. So if you need to compare them, be careful that this toggle remains disabled.
    Aaron P Scooter Software