Coloring white space in git-diff's output

后端 未结 4 1677
故里飘歌
故里飘歌 2020-11-27 10:17

Regarding code formatting I\'m kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show

4条回答
  •  粉色の甜心
    2020-11-27 10:44

    Use git diff -R to turn removed lines into added lines. Then trailing whitespace will be highlighted.

    (This assumes you already have whitespace hightlighting enabled, as per the colour settings from Mark's answer. Credit for this method goes to Junio's post at http://git.661346.n2.nabble.com/Highlighting-whitespace-on-removal-with-git-diff-td5653205.html .)

    For example, when converting a file from DOS line endings to Unix, git diff -R clearly shows me the ^M characters (dis)appearing at the ends of lines. Without -R (and also without -w etc.) it shows that the entire file has changed, but doesn't show how.

提交回复
热议问题