dchhetri
dchhetri

Reputation: 7136

How can I merge whitespace diffs from file B to file A?

I want to merge whitespace diffs from file B to file A, but not merge non whitespace diffs as I want to navigate through them and examine one by one? Is this possible?

Upvotes: 1

Views: 124

Answers (1)

Drew
Drew

Reputation: 30701

Use ediff (e.g. ediff-buffers). Use ## to toggle skipping whitespace comparison. I know of no way to go to the next whitespace-only difference. But you can at least go through the differences one-by-one and apply a diff region only when the only differences are whitespace. ## toggles skipping over whitespace-only differences.

You can use either state of ## for cycling:

  • If skipping whitespace diffs is on then you can cycle through the diffs using n and notice when one or more diffs are skipped (all diff regions are highlighted, so you can tell). When that happens, put your cursor in the diff region that differs only by whitespace and use ga or gb to bring Ediff to that region in both buffers. Then use a or `b' to copy one region to the other.

  • If skipping whitespace diffs is off then you can cycle as above, and just eyeball whether a region differs only by whitespace. Use a or b when that is the case.

Other than that, you could probably code something up that does what you want more directly. I don't think it already exists, but it might.

You might check the Ediff manual (I didn't notice anything that would help, however). Be aware that the Ediff manual uses "white space" (two words), not "whitespace", if you try ssearching (C-s).

Upvotes: 1

Related Questions