Skip to main content
clarify
Source Link
Thomas Dickey
  • 79.2k
  • 9
  • 189
  • 289

One approach that often works is to increase the amount of context, so that adjacent small differences will be collected into a more cohesive display.

  • In the command-line diff, you would do this with the -C option.
  • With vimdiff, you would do this with the diffopt setting, and the context feature, e.g., this is the implicit default:
    set diffopt=filler,context:6

and you could change that, e.g.,

    set diffopt+=context:9
    set diffopt=filler,context:9

Other than that:

  • the underlying diff utility has no way to detect that lines are interchanged with respect to each other.
  • nor does it have a way to compare files while ignoring certain columns.

The example given appears to be a series of transactions by date. If there is some other ordering (which tends to make larger chunks of unchanged lines) then re-ordering the data would help.

In principle, you could use the diffexpr setting, and construct a script which pre/post-processes your data so that only certain columns are compared. I used that approach a while back to make a free-format (word-level) compare utility. But doing that is a fair amount of work, and not simple due to diff's inability to ignore columns of its input.

One approach that often works is to increase the amount of context, so that adjacent small differences will be collected into a more cohesive display.

  • In the command-line diff, you would do this with the -C option.
  • With vimdiff, you would do this with the diffopt setting, and the context feature, e.g., this is the implicit default:
    set diffopt=filler,context:6

and you could change that, e.g.,

    set diffopt+=context:9
    set diffopt=filler,context:9

Other than that:

  • the underlying diff utility has no way to detect that lines are interchanged with respect to each other.
  • nor does it have a way to compare files while ignoring certain columns.

The example given appears to be a series of transactions by date. If there is some other ordering (which tends to make larger chunks of unchanged lines) then re-ordering the data would help.

One approach that often works is to increase the amount of context, so that adjacent small differences will be collected into a more cohesive display.

  • In the command-line diff, you would do this with the -C option.
  • With vimdiff, you would do this with the diffopt setting, and the context feature, e.g., this is the implicit default:
    set diffopt=filler,context:6

and you could change that, e.g.,

    set diffopt+=context:9
    set diffopt=filler,context:9

Other than that:

  • the underlying diff utility has no way to detect that lines are interchanged with respect to each other.
  • nor does it have a way to compare files while ignoring certain columns.

The example given appears to be a series of transactions by date. If there is some other ordering (which tends to make larger chunks of unchanged lines) then re-ordering the data would help.

In principle, you could use the diffexpr setting, and construct a script which pre/post-processes your data so that only certain columns are compared. I used that approach a while back to make a free-format (word-level) compare utility. But doing that is a fair amount of work, and not simple due to diff's inability to ignore columns of its input.

Source Link
Thomas Dickey
  • 79.2k
  • 9
  • 189
  • 289

One approach that often works is to increase the amount of context, so that adjacent small differences will be collected into a more cohesive display.

  • In the command-line diff, you would do this with the -C option.
  • With vimdiff, you would do this with the diffopt setting, and the context feature, e.g., this is the implicit default:
    set diffopt=filler,context:6

and you could change that, e.g.,

    set diffopt+=context:9
    set diffopt=filler,context:9

Other than that:

  • the underlying diff utility has no way to detect that lines are interchanged with respect to each other.
  • nor does it have a way to compare files while ignoring certain columns.

The example given appears to be a series of transactions by date. If there is some other ordering (which tends to make larger chunks of unchanged lines) then re-ordering the data would help.