On 2009-05-11, anokun7 <[email protected]> wrote:
> I tried using google, but couldnt get an answer, so here I am, please
> suggest / help
>
> I have 2 files (FILE 1 is an older version of FILE 2) - each contain a
> list of account id's (hence are unique and sorted - let's assume) like
> the following:
>
> FILE 1
> ***************
> ab123
> bc123
> bv345
> jd811
> jk11
> ak15
>
> FILE 2
> ***************
> ab123
> bc123
> jd811
> hij12
> jk110
> ak15
>
> When I look at the files using vimdiff, I can see the differences
> between the two files. What I want to achieve are two things - the
> second is more important I think:
>
> 1. Enable line level differences: that is the line jk11 in FILE 1
> should show as deleted in FILE 2.
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
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---