我正在使用带有 --color-words 的 git 来查看我的差异。在我的差异中,它显示我删除了
<b>{{ljcount}}</b> Changes
我补充说:
<b>{{skills_limits}}</b> Changes
这比我希望的要大(我希望单词边界位于 {} 处)。我尝试使用 --word-diff-regex
,但我找不到使其工作的正则表达式。我怎样才能达到这个结果?
最佳答案
来自git help diff
:
--word-diff-regex=<regex>
Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies
--word-diff unless it was already enabled.
下面的表达式将使一个单词成为任何字符串和下划线,或任何非空白字符。
$ git diff --color-words --word-diff-regex='\\w+|[^[:space:]]'
关于regex - Git - 不包括{}的颜色词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8483041/