4

With "diffEditor.ignoreTrimWhitespace": false, changes in a diff editor:

enter image description here

With "diffEditor.ignoreTrimWhitespace": true, changes in a diff editor:

enter image description here

With "diffEditor.ignoreTrimWhitespace": true, changes in a normal (non-diff) editor:

enter image description here

How to ignore changes in leading/trailing whitespace in a non-diff editor as well?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
  • Git has no concept of a "diff editor" or "non-diff editor", but if you are talking about the `git diff` *command*, it has a `-w` flag and some finer-grained flags for controlling how whitespace changes are handled. I think, though, that you mean this question to be specific to visual studio code *only*, in which case, you should remove the [tag:git] and [tag:git-diff] tags. – torek Aug 17 '21 at 08:29
  • @torek Thanks for pointing out, it's a question of the vscode and git integration, I've removed the `git-diff` tag. – Wenfang Du Aug 17 '21 at 08:47
  • 1
    It looks like you are referring to the `SCM: Diff Decorations` settings. I don't see a setting for ignoring whitespace in those. – Mark Aug 17 '21 at 09:33

3 Answers3

2

For others, your issue has been closed with a fix, see Add option to ignore changes in trim whitespace in quick diff .

The new setting is:

SCM: Diff Decorations Ignore Trim Whitespace

Controls whether leading and trailing whitespace is ignored in Source Control diff gutter decorations.

Options:

  1. true: Ignore leading and trailing whitespace
  2. false: Do not ignore leading and trailing whitespace (default)
  3. inherit: Inherit from diffEditor.IgnoreTrimWhitespace

This new setting is working in the Insiders' Build (and so may be out in v1.63) - it only affects whether those scm gutter decorations appear when they are caused by leading or trailing whitespace.

Mark
  • 143,421
  • 24
  • 428
  • 436
0

Just want to add that if you'd like to quickly toggle ignoring leading/trailing whitespace, you could use the setting "scm.diffDecorationsIgnoreTrimWhitespace": "inherit" and assign a shortcut for toggle.diff.ignoreTrimWhitespace, I'm using Alt+Y for this.

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
-1

There is a "Show Leading/Trailing Whitespace Differences" button on the top right corner in the diff view.See below image enter image description here

enter image description here

Bhargav Variya
  • 725
  • 1
  • 10
  • 18