I would like to use the difftastic diff tool, which ignores whitespace changes in code (amongst other useful functionalities), and I have set my .gitconfig
to use difft
(the binary file of difftastic) as my preferred external diff tool using this command:
git config --global diff.external difft
And, my .gitconfig
has these lines in it:
[diff]
external = difft
However, the VSCode text editor still shows whitespace diffs. I have searched for a way to change the diff tool in VSCode to no avail, the only results are "How to set VSCode as the default merge/diff tool for git".
To clarify, I would like to change the diff tool used by the vscode text editor section as well as the diff viewer. I do not want to change the tool used by the commandline git
command itself. In the image I’ve linked, it shows changes for whitespace, which should not be happening if difft
is set as the diff tool.
2
Answers
You can change the tool Git uses to "diff" two files: https://git-scm.com/docs/git-difftool (this is Git functionality – it has nothing directly to do with VSCode).
You can substitute a custom editor for the built-in the Visual Studio code editor: https://code.visualstudio.com/api/extension-guides/custom-editors.
You can add a custom "diff" plugin to Visual Studio, for example, "Partial Diff": https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff.
What you CANNOT do is swap in a custom app to change the "diff" functionality of the default VSCode editor.
Visual Studio Code does not use an external utility to compute the diff. The necessary algorithms are directly implemented in VS Code and you don’t have any control over them.
Using an arbitrary external utility would most likely not result in a good user experience either. If VS Code cannot understand the generated diff, it would not be able to display the output with the diff editor and you would lose features like syntax highlighting.
However, I may have an alternative solution to your original problem (using difftastic in VS Code). I am currently working on my own extension that adds a semantic diff mode to VS Code. It supports fewer languages than difftastic, but has additional features like moved code detection:
If that is what you are looking for, you can find the extension (SemanticDiff) in the Visual Studio Code Marketplace.