在Visual Studio代码中设置自定义git diff命令(--word-diff)

ant*_*nty 9 git git-diff visual-studio-code

我们有一个JSON文件,其中包含大型文本作为JSON对象中的字符串.那些字符串以及它们所处的线条相当长.在对文本进行更改时,我们希望更好地了解更改.

git diff --word-diff
Run Code Online (Sandbox Code Playgroud)

在控制台上完美地工作以可视化已更改的单词.

我创建了一个diff-wrapper.sh脚本,使其成为默认行为:

#!/bin/sh
git --no-pager diff --color-words "$2" "$5"
exit 0
Run Code Online (Sandbox Code Playgroud)

并设置它(对于此存储库):

git config diff.external ./diff-wrapper.sh
Run Code Online (Sandbox Code Playgroud)

现在,我想在VS Code的diff窗口中看到相同的输出,但我没有.

是否有实现这一目标的环境?通过使VS代码为该存储库使用本机git diff命令或在VS Code首选项中设置类似的"外部"diff命令?在https://code.visualstudio.com/docs/customization/userandworkspace上,我只找到diff编辑器的这些选项:

// Controls if the diff editor shows the diff side by side or inline
"diffEditor.renderSideBySide": true,

// Controls if the diff editor shows changes in leading or trailing whitespace as diffs
"diffEditor.ignoreTrimWhitespace": true,
Run Code Online (Sandbox Code Playgroud)

另外:终端在diff中包含长行,VS Code没有.是否有设置在差异中做到这一点?

Mar*_*ark 1

关于你问题的这一部分已经有了进展:

另外:终端会在 diff 中换行长行,而 VS Code 不会。有没有一个设置可以在差异中做到这一点?

请参阅https://github.com/microsoft/vscode/pull/110268在 diff 编辑器中支持自动换行。

它应该很快就会发布 Insiders' Build v1.52。