8

When using vimdiff, it highlights the differing portion of the lines in a "greedy" fashion. That is, when comparing two lines:

Left window: This one is his home

Right window: That one is her home

then the whole line is colored pink, but on the left, is one is his and on the right at one is her parts are highlighted in red, as a mismatch:

This one is his home
That one is her home

How can I make vimdiff only highlight the actual differences?

This one is his home
That one is her home

ysap
  • 7,723
  • 7
  • 59
  • 122

2 Answers2

10

Please visit https://github.com/rickhowe/diffchar.vim instead of https://github.com/vim-scripts/diffchar.vim. Thank you.

Rick Howe
  • 429
  • 3
  • 6
  • Thanks, Rick - saw your answer after downloading and installing from @sudo's answer. I assume you are the author of the plugin? Is there a difference between the versions in the two repos (other than the much better Readme)? – ysap Jul 23 '17 at 13:46
  • Yes, diffchar.vim is my plugin. Please use https://github.com/rickhowe/diffchar.vim, which includes the latest version and is my own github repository. – Rick Howe Jul 23 '17 at 14:54
3

There is nothing built-in in vim to achieve this but you can use diffchar.vim to achieve this.

After installing plugin, vimdiff will give you character wise diff. You can toggle between this mode and normal diff using F7 key

From plugin Readme:

For example, in diff mode: ([DiffText], )

(file A) The [quick brown fox jumps over the lazy] dog. 
(file B) The [lazy fox jumps over the quick brown] dog. 

this plugin will exactly highlight the changed and added units:

(file A) The [quick] <brown >fox jumps over the [lazy] dog. 
(file B) The [lazy] fox jumps over the [quick] <brown >dog. 
Community
  • 1
  • 1
sudo bangbang
  • 27,127
  • 11
  • 75
  • 77