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

标签 git visual-studio-code git-diff

我们有一个 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/

相关文章:

git - 重命名本地 GIT 分支会破坏 SourceTree 中的 Git Flow

latex - VScode : Stop autocompilation Latex toolchain

c++ - 关于 IncludePath 的 MinGW 和 Perl 冲突

无法识别类型(双复合体)

Git 差异 : is it possible to show ONLY changed lines

git - "insertions and deletions"是什么意思以及数字是如何计算的

git 记录文件的一部分

git - 将 git repo 克隆到一个非空文件夹

git - 基于gitlab的composer私有(private)包被识别为git子模块

git - 使用 git hooks 为当前提交更改的每个文件创建差异报告