Sunday, August 22, 2010

Re: vimdiff-like highlighting within the same file?

Hi Adam!

On Fr, 20 Aug 2010, Adam Monsen wrote:

> > How would you like the plugin to handle that automatically. If you make
> > good suggestions, I might implement that.
>
> Do you mean the narrow region plugin? Actually, that plugin may not be
> involved at all.
>
> Here's a use case for what I'm envisioning.
>
> (1) one plain text file in unified diff format is opened in vim
> (2) vim auto-detects that this is a unified diff file
> (3) for lines that have changed, the *parts* of lines that have
> changed are specifically highlighted (similar to the highlighting
> provided when two files are opened with vimdiff)
>
> Here's a mockup:
> * http://yfrog.com/j1vimintrafilediffhighligp
> * http://imagebin.ca/view/LmlbQoR.html
>
> Bonus use case step:
>
> (4) provide keybindings that can
> (a) cycle through differences
> (b) cycle through intra-line differences
>
> Does that make sense?

Well, Andy provided a short script for po files, that attempted to
overlay diff-highlighting to changed regions. Something like this might
be possible with unified diff files, although I am not sure how to get
the right lines to compare with.

So I went the other way and hacked my NrrwRgn Plugin to provide the :NUD
(Narrow Unified Diff, it does not really make sense, to use :NUD in any
other filetype) command, that opens a chunk in diff mode in a separate
window.
:NUD will open the chunk on which the cursor is currently in 2 new split
windows in diff mode and whenever you move around in your patch file,
use :NUD to update your windows. (I find it easy enough to navigate in
such a patch file [/^@@ to move to the next chunk], so I did not include
a mapping to move to the next chunk, besides, such a mapping would not
fit well into the NarrowRegion plugin anyway, but would need to be in a
filetype specific plugin).

This is an experimental feature, but please try it out. Unfortunately
vim.org seems to have database problems currently, but you can also get
it from http://github.com/chrisbra/NrrwRgn (the NrrwRgn.vba file
contains everything). Granted, this is not exactly what you asked for,
but this seems to work well enough.

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: