我们有一个 JSON 文件,其中包含大文本作为 JSON 对象内的字符串。这些字符串以及它们所在的行变得很长。
在对文本进行更改时,我们希望更好地看到更改。
git diff --word-diff
在控制台上非常适合可视化已更改的单词。
我创建了一个 diff-wrapper.sh 脚本来使其成为默认行为:
#!/bin/sh
git --no-pager diff --color-words "$2" "$5"
exit 0
并设置它(对于这个存储库):
git config diff.external ./diff-wrapper.sh
现在,我想在 VS Code 的差异窗口中看到相同的输出,但我没有。
是否有实现这一目标的设置?是通过让 VS Code 对该存储库使用 native git diff 命令还是在 VS Code 首选项中设置类似的“外部”diff 命令?
在 https://code.visualstudio.com/docs/customization/userandworkspace ,我只找到差异编辑器的这些选项:
// 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,
另外:终端在 diff 中包含长行,而 VS Code 没有。是否有设置可以在差异中做到这一点?
最佳答案
关于你问题的这一部分,有一些动向:
Additionally: The terminal wraps long lines in the diff, VS Code does not. Is there a setting to do that in diffs?
见 https://github.com/microsoft/vscode/pull/110268在差异编辑器中支持自动换行。
它应该很快就会进入 Insiders' Build v1.52。
关于git - 在 Visual Studio Code 中设置自定义 git diff 命令 (--word-diff),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36066118/