如何获得没有前面字符的差异输出?

时间:2016-01-29 15:10:11

标签: formatting diff

有没有办法提出一个更复制粘贴友好的差异,这意味着没有像统一格式(+ - )或默认格式(<>)那样的前面的字符?也许用额外的行上的标记包围更改的代码,如下所示:

some_context code
++++ Added 3 lines:
line 1
line 2
line 3
++++ END added lines
some context code
---- Deleted 1 line:
deleted line
---- END deleted line
some context code

而不是

some_context code
+ line 1
+ line 2
+ line 3
some context code
- deleted line
some context code

1 个答案:

答案 0 :(得分:1)

阅读完文档后,您确实可以使用line-formatgroup-format参数指定自己的格式。

以下是我需要的文档中的示例:

diff \
        --unchanged-group-format='' \
        --old-group-format='-------- %dn line%(n=1?:s) deleted at %df:
     %<' \
        --new-group-format='-------- %dN line%(N=1?:s) added after %de:
     %>' \
        --changed-group-format='-------- %dn line%(n=1?:s) changed at %df:
     %<-------- to:
     %>' \
        old new

链接: