3

I am new to vimdiff and had a question about outputting the similarities of the two or more files into a new file. For example, based on the following picture I would like to have b,c,e,f,a along with the names of the two files being compared outputted to a different file.

An example file template for this might be:

[file1's name][file2's name]

lines that were similar between both files

you really need to see the picture

Is there any built in vim command to do this or some bash script I could write that would be able to extract the data needed from vim? Thank you in advance!

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Javed Ahamed
  • 2,804
  • 6
  • 32
  • 41

1 Answers1

2

You could use regular diff to get the output if you have it installed:

diff  --unchanged-line-format='%L' --old-line-format='' \
  --new-line-format='' a.txt b.txt

You would run that from the command line on Linux. Or from within Vim you would run it by typing :! first as follows:

:!diff  --unchanged-line-format='%L' --old-line-format='' \
  --new-line-format='' a.txt b.txt
richq
  • 55,548
  • 20
  • 150
  • 144
  • sorry I am new to all this how do you run that command from vim? – Javed Ahamed Jun 29 '09 at 19:25
  • I've clarified what I meant. Vim seems to use diff under the hood so it should work on all platforms. I assume Linux as I haven't much experience with Windows, so I don't know how this would work there. – richq Jun 29 '09 at 19:36
  • Thanks! Now i have to figure out how to add this functionality to more than 2 files at a time ^_^. – Javed Ahamed Jun 30 '09 at 14:07