linediff.vim icon indicating copy to clipboard operation
linediff.vim copied to clipboard

Provide keybindings to jump between differences

Open hupfdule opened this issue 3 years ago • 4 comments

On longer lines (e.g. in logfiles) it may be hard to spot the differences even if they are highlighted. It would therefore be nice to have some keybindings to jump to the next/prev difference, like ]d and [d.

hupfdule avatar Jun 28 '22 14:06 hupfdule

When diffing areas, what's used its Vim's built-in "diff mode", and you could jump between changes with [c and ]c -- take a look at :help jumpto-diffs. You could remap them, although it might be tricky to do it just in diff mode. Does that work for you, or did you mean a different kind of jump?

AndrewRadev avatar Jun 29 '22 15:06 AndrewRadev

Thanks for the hint, but that was not exactly what I had in mind.

These movements are linewise movements. They jump to the next line that differs. But they don't jump the next difference inside the line. As linediff colors the actual differences in a line I was expecting that it would be possible to jump to the next such difference. But if only the internal vimdiff feature is used, maybe that is not possible.

hupfdule avatar Jun 29 '22 18:06 hupfdule

I see what you mean, yeah. Unfortunately, the plugin doesn't use anything special other than the built-in vimdiff. Theoretically, I could walk character by character to find the beginning of a syntax group, but that feels outside of the scope of the plugin. I did, however, find a few attempts at a general solution:

  • https://www.reddit.com/r/vim/comments/18brrj/comment/c8dlhiq/?utm_source=share&utm_medium=web2x&context=3
  • https://github.com/rickhowe/diffchar.vim
  • https://superuser.com/questions/145940/vimdiff-jump-to-next-difference-inside-line

If you try some of these options out and they work well for your use cases, but they require some special command, I can add an option to the plugin to use it instead of the built-in diff.

AndrewRadev avatar Jun 30 '22 17:06 AndrewRadev

I think since Vim does the diffing and has all the information about it, the best place to implement such mappings is in Vim itself. It will also make it work not just in this plugin. Please consider bringing it up in https://github.com/vim/vim/issues

xaizek avatar Jul 09 '22 10:07 xaizek