如何将,
作为git diff --word-diff的词分隔符来添加?同样使用逗号作为分隔词中的分隔符
比如我想DIFF认识到
function(A,B,C) -> function(A, B, C)
只增加了而不是替换整行的空间。
如何将,
作为git diff --word-diff的词分隔符来添加?同样使用逗号作为分隔词中的分隔符
比如我想DIFF认识到
function(A,B,C) -> function(A, B, C)
只增加了而不是替换整行的空间。
使用--word-diff-regex
:
--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.
Every non-overlapping match of the <regex> is considered a word.
Anything between these matches is considered whitespace and
ignored(!) for the purposes of finding differences. You may want to
append |[^[:space:]] to your regular expression to make sure that
it matches all non-whitespace characters. A match that contains a
newline is silently truncated(!) at the newline.
The regex can also be set via a diff driver or configuration
option, see gitattributes(1) or git-config(1). Giving it explicitly
overrides any diff driver or configuration setting. Diff drivers
override configuration settings.
我从来没有使用过,但我想这可能git diff --word-diff-regex="[^[:space:],]+"
工作。
您也可以尝试-w
/--ignore-all-space
,虽然这可能会忽略比您更喜欢的更多空格。
-b忽略少许空格 –
除了KurzedMetal的回答:没有引号,它的效果更好,因为它不会打击TAB时我的bash自动完成。
git diff --word-diff-regex=[^[:space:],]+
它的工作:-) – oberlies
不知道如何设置它在混帐配置,默认使用这个表达式,当我指定--word-DIFF而不是我每次都指定正则表达式。 – sibaz
回答了我自己的问题:'git config --global diff.wordRegex [^ [:space:],] +' – sibaz