Search code examples
beyondcompare4

Beyond Compare, special marker for expected diff lines in a file


How can one create a section of a file thats always expected to be different?

Sample jenkinsfile (basically javascript):

//!beyond-comp:ignorediff

//!beyond-comp:ignorediff-end

Sample CMD script:

REM!beyond-compare:ignorediff
set VAR1=some_specific_value
set VAR2=some_value
REM!beyond-compare:ignorediff-end

Sample YAML:

#!beyond-comp:ignorediff
environment:
- var1: some_specific_value
- var2: some_value
#!beyond-comp:ignorediff-end

primary use case is batch file/jenkinsfile/etc with a section that is 100% expected to be different between repos, ie setting specific values, where its cumbersome to use env variables

I'm assuming theres a Grammar thing to do this, but I looked through it and couldn't make heads or tails of it


Solution

  • To mark text unimportant in Beyond Compare 4's Text Compare for *.cmd files:

    1. Select Tools > File Formats.
    2. Click +.
    3. Text Format.
    4. General tab.
    5. Mask: *.cmd.
    6. Grammar tab.
    7. Click + in the top half of the tab.
    8. Element name: ignorediff.
    9. Category: Delimited
    10. Text From: !beyond-compare:ignorediff.
    11. to: !beyond-compare:ignorediff-end.
    12. Click OK.
    13. Save.
    14. Close the File Formats dialog.
    15. Load a pair of CMD files in the Text Compare.
    16. Click the Rules toolbar button (referee icon).
    17. Uncheck the ignorediff grammar element to make it unimportant.
    18. Change the dropdown at the bottom of the dialog from Use for this view only to Also update session defaults.
    19. Click OK.
    20. Make sure View > Ignore Unimportant Differences is turned on.

    Reference: Define Unimportant Text in Beyond Compare.