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

With "diffEditor.ignoreTrimWhitespace": false, changes in a diff editor:
With "diffEditor.ignoreTrimWhitespace": true, changes in a diff editor:
With "diffEditor.ignoreTrimWhitespace": true, changes in a normal (non-diff) editor:
How to ignore changes in leading/trailing whitespace in a non-diff editor as well?

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:
true: Ignore leading and trailing whitespace
false: Do not ignore leading and trailing whitespace (default)
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.

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.

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

Related

VSCode inline diff peek view doesn't show whitespace difference

When I change the indentation, Diff Decorations Gutter shows that this line is modified, and open changes with previous revision shows the whitespace difference.
However, when I click the decoration gutter, there is no diff in peek view. How to show the whitespace diff in peek view?
VSCode version: 1.69.2
My settings:
SCM: Diff Decorations Ignore Trim Whitespace - false
Diff Editor: Ignore Trim Whitespace - false
Decorations Gutter & inline diff peek view
open changes with previous revision

Netbeans 12 "diff window" does not always highlight added or removed spaces in the code

I upgraded Netbenas 8 to Netbeans 12 and now my diff window does not always highlight added or removed spaces in the code.
It does highlight if spaces was added or removed in the middle of the line (after a non space character), and before a non space character.
But it does not highlight when the space was added or removed form the beginning of the line, or at the end of the line. Preceding and trailing spaces change does not get highlighted.
I tried restarting Betbeans - it did not help.
I checked HTML, PHP, TXT source code, all have the same problem.
Is there any config parameter to fix it, or is it a bug?
Navigate to Tools > Options > Miscellaneous > Diff
By default, the checkbox Ignore Leading and Trailing White Space is checked:
Just uncheck the checkbox, then click the OK button. Diff will then report on leading and trailing space differences.

Make VSCode Diff Editor ignore empty line addition/deletions?

I want VSCode to ignore empty lines added/removed from showing up in the diff editor.
I can trigger ignore trailing/leading whitespaces by a toggle on the editor, but it does not seem to work on lines.
Current Diff Editor:

How do you remove trailing spaces in all files except Markdown?

In Visual Studio Code the setting
"files.trimTrailingWhitespace": true
removes trailing white space when files are saved, or Shift + Alt + F is used to format a file, but this breaks Markdown formatting.
How do you selectively turn off white space trimming for Markdown?
Add this line to your settings.json file.
"[markdown]": {
"files.trimTrailingWhitespace": false
}
You can use EditorConfig by adding .editorconfig at the root of your project:
[!markdown]
trim_trailing_whitespace: false
Or as GollyJer suggested, add this code snippet in the settings.json file:
"[markdown]": {
"files.trimTrailingWhitespace": false
}
You can now (VSCode 1.68, May 2022) do this through the Settings GUI instead of directly your settings.json.
Settings editor improvements
The Settings editor now shows a default value override indicator for language-specific settings.
As a note, one can view language-specific settings by adding a language filter in the Settings editor search bar, and one can add such a filter either by typing it out explicitly, or by clicking the filter button on the right of the search bar, and selecting the "Language" option.
When the default value override indicator shows up, it indicates that the default value of the language-specific setting has been overridden by an extension. The indicator also indicates which extension overrode the default value.
(Theme Light Pink)
This example above is for line wrapping, but you can adapt it to reference trim_trailing_whitespace.
Do Ctrl-K s. This will "Save without formatting", which also means, without trimming trailing whitespace in the file you're editing
Solution
Add or update .editorconfig in root of your project and add the 2 following lines to prevent trimming on whitespace in VScode on matching file extension's
Update .editorconfig with following
[*.md]
trim_trailing_whitespace = false
[*.mdx]
trim_trailing_whitespace = false

VSCode Extension createTextEditorDecorationType ignore whitespace

I'm working on an extension which colors some text within the editor based on some condition. Unfortunately, it looks like the style applied to the text is also applied to the whitespace characters when the user has editor.renderWhitespace enabled.
I can't find anything in the API which gives the option of ignoring the whitespace when coloring.
Does anyone know of a way to leave the color of the whitespace characters intact?
There is a setting to change the color and opacity of whitespace characters when made visible as discussed here. It says that you could use:
"workbench.colorCustomizations": {
"editorWhitespace.foreground": "#FF0000"
}
The colors for the whitespace is taken from the invisibles property in themes, so the color is customizable via themes.
<key>invisibles</key>
<string>#3B3A32</string>
for more information please read this issue here