Vim offers a tool to see the difference between two buffers and put contents from one to another: diffthis (see :h :diffthis).
To get this diff mode you can either start it from the command line with:
$ vimdiff file1 file2
Or from within Vim:
- Open both of the buffers.
- create a split window to get both of the buffers on your screen. (with
:split and :e for example)
- Start the diff mode with
:windo diffthis
- Use
:diffput and :diffget to modify the content of the buffers (:h :diffput and :h :diffget).
- Use
:diffoff to stop the diff mode.
Now to put the diff of the files in a third one I would recommend to use the diff from the (shell) command line with something like (See man diff):
$diff file1 file2 > file3
From within Vim you can get the result of this command in a buffer with:
:read !diff file1 file2
read allows to get the result of a command in the current buffer and ! allows to specify a string to be executed as an external command (here diff file1 file2)