Git - 不包含{}的颜色词 [英] Git - Color words excluding {}

查看:130
本文介绍了Git - 不包含{}的颜色词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用git和--color-words来查看我的差异。在我的差异中,它显示我已删除

 < b> {{ljcount}}< / b>& nbsp ; & nbsp;更改

我补充说:

 < b> {{skills_limits}}< / b>& nbsp;& nbsp;& nbsp;变更

这比我想要的要大(我希望字边界在{}处)。我试着玩弄 - word-diff-regex ,但是我找不到一个正则表达式来使它工作。我怎样才能达到这个结果?



  --word-diff-regex =< regex> 
使用< regex>来决定一个单词是什么,而不是将非空白字符视为一个单词。也意味着
--word-diff,除非它已经启用。

以下表达式将使单词成为任何字符串和下划线,或任何非空白字符。

pre $ git diff --color-words --word-diff-regex ='\\w + | [^ [:space:]]'


I am using git with --color-words to view my diff. In my diff, it shows that I removed

<b>{{ljcount}}</b>&nbsp;&nbsp;&nbsp;Changes

And that I added:

<b>{{skills_limits}}</b>&nbsp;&nbsp;&nbsp;Changes

This is larger than what I would like it to be (I want the word boundary to be at the {}). I tried playing around with --word-diff-regex, but I couldn't find a regex to make it work. How can I achieve this result?

解决方案

From 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.

The following expression will make a word be any string of characters and underscore, or any non-whitespace character.

$ git diff --color-words --word-diff-regex='\\w+|[^[:space:]]'

这篇关于Git - 不包含{}的颜色词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆