2

I found some instructions on how to show/hide differences in comments using beyond compare. However most of the answers show how to set comment as important text or not. That is, if a portion of code is commented on both sides then check if the comment are different or not.

I would like to ignore when only one side of the comparison is commented. In other words if I have

# # line1
# line2

on one side and

# line1
line2

I would like both lines to be marked as "unimportant differences" (if indeed the text is the same, otherwise to be marked as differences).

Manfredo
  • 1,760
  • 4
  • 25
  • 53

1 Answers1

2

Beyond Compare will only compare text if it is of the same grammar element type. If one side is regular code and the other side is a comment, it will always mark it as an important difference.

To make regular text on one side and the same text commented on the other side show as a match, you'll need to edit the definition of a comment in the file format.

  1. To edit a format, open Tools > File Formats.
  2. Select the format that matches your files.
  3. Go to the Grammar tab.
  4. Select the Comment grammar element, which might be defined as # to end of line.
  5. Click the Edit (gear) button.
  6. Set the Category radio button to Basic.
  7. Text matching: ^#\s
  8. Check Regular expression.
  9. Click OK, then Save.

The updated file format will treat # followed by a whitespace character as an unimportant comment, the remaining text in the line will be treated as regular text and compared to the other side.

Chris Kennedy
  • 2,639
  • 12
  • 11
  • Hi Chris, I tried your solution and it works, however my idea was also to have that portion of text marked as unimportant difference. Would that be possible? – Manfredo Jun 12 '17 at 08:59
  • Beyond Compare doesn't provide a method to make a comment on one side and default text on the other side an unimportant difference. If text is of different grammar element types, it will always be an important difference. Modifying the file format so both sides are the same grammar element type is the only workaround. To aid debugging grammar definitions, the grammar element type at the current cursor position is displayed in the status bar at the bottom of the window. – Chris Kennedy Jun 12 '17 at 20:09