No announcement yet.

Strict comparisions: align only if exact match

  • Filter
  • Time
  • Show
Clear All
new posts

  • Strict comparisions: align only if exact match

    I'm looking for a way to align based on a strictly comparison of part a line. For example,



    BC partial matches dog to frog and aligns them, but as variables these are completely different. Thus, I'd like a strict comparison that says if some expression does not match, like (^\w+=), then lines should not align.

    Is this possible? Seems like there should be a "Strict" checkbox for grammar. Or better yet, strictly match only part of a RegEx by allowing users to specify which groups of the RegEx must match. E.g., set (^\s*)(\w+)(\s*=) then specify a strict match only on $2, which, assuming my noob RegEx is right, should exactly match the word between the start of a line and the first equal sign, ignoring any differences in leading & trailing spaces.

    This could improve alignment for everything, like ensuring "if orange = 1" doesn't partial match and align to "for range = 1 to 10", which is obviously completely different code.

  • #2

    For examples like this, you can try a few different things. One way I've found to be effective is to define a Grammar element for your Variables (^.*= or a similar RegEx).

    Then go to the Session Settings, and mark Variable as important, and uncheck Everything Else marking it as Unimportant. This way differences detected in the variable name are red, and other differences are blue (toggle Ignore Unimportant Differences in the toolbar to Off).

    Then in the Session Settings, Alignment tab, check Never Align Differences. This will then not align your variable names, but mark any differences in values as blue.

    Alternatively, you can assign Line Weights (under File Formats) and tweak Alignment options to align your text differently.
    Aaron P Scooter Software


    • #3
      Well, that's a novel hack. Convoluted, but at least it works. (I better copy these instructions somewhere safe--I'll never remember then otherwise.)

      I tried the line weights before but could never see any changes in alignment. I suppose line weights don't help much in registry & INI files since there's really only 1 line type.

      I still think a "strict" option would be easier. Plus, it would help more complicated alignment like XML elements, which always drive me crazy when BC matches a bunch of random letters for lines with completely different elements.

      Anyway, thanks for the suggestion. I'll play with it and maybe find a way to match base elements in XML, too.