If they're flagged as different, I occasionally use this stunt:
:let @a=''|g/^/if diff_hlID(line('.'), 1) | sil! y A | endif
This yanks all the changed/added into the "a" register (which
means you'd have to run it in FILE2 instead of FILE1 to get the
ones that were added, because you can't yank content where it
doesn't exist :)
You're still left with the problem of getting the diff to be
linewise.
Alternatively, if the data isn't too crazy (no regexp metachars
in it) I've used
:%s@.*@:g/^&$/sil! >
to turn one buffer into a bunch of Ex commands (in this case,
shifting lines that match; but you could use "d" instead of ">"
if you want to nuke the matching lines), and then yank the entire
buffer:
:%y
then executing
@"
in the other window to replay that buffer as a macro. It's a
little down-and-dirty but it gets the job done when I need to
compare two files.
Hope this gives you some ideas...
-tim
Vim does its best to show differences at the character level and I
don't know of a way around that.
> 2. Extract all deleted lines from FILE 1 into a buffer or another
> file. That is: lines bv345, jd811, jk11.
>
> Is this possible using vimdiff - I assumed that this a variant of
> generating a patch, but couldnt proceed beyond that.
When I need to do things like this, I use command-line tools such as
comm and diff. If the files are sorted (which your examples
aren't), you can use comm like this,
comm -23 file1 file2 > uniq1
where uniq1 will contain the lines appearing only in file1.
Alternatively, you could use diff like this,
diff file1 file2 | sed -n '/^</s/^..//p' > uniq1
Regards,
Gary
Another option if I understand the question correctly is the
WhatsMissing plugin.
http://www.vim.org/scripts/script.php?script_id=1108
It can check at the Word or Line level.
It can also ignore case and white space.
Just load the 2 buffers and type :WhatsMissing, it will prompt you for
the options.
It is good to have options.
HTH,
Dave