Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use vimdiff to replace entire file?

I'm using vimdiff for a git merge. Is there a quick way to select 1 file to use, right now i'm just selecting everything from one buffer, replacing the $MERGE with that, and then saving. I guess I can macro that, but was wondering if there is a better way. Thanks!

like image 235
mazlix Avatar asked Jun 06 '11 19:06

mazlix


2 Answers

Several ways:

:%diffput

to do 'put' all changes from the current buffer to the 'other' buffer. This makes it easy with three-way diffs:

:%diffput OURS

The 'OURS' pattern will match uniquely on buffernames participating in the current diff

All the above can be done in reverse, substituting do or :diffget

like image 99
sehe Avatar answered Oct 11 '22 23:10

sehe


You should take a look at Tim Pope's Fugitive plugin. It's a really usefull plugin.

When you run Gdiff in a conflicted file, 3 files are opened - target, merged and working copy. You would switch to the file you want to save, and execute Gwrite! to save that file.

There is a whole Vimcast explaining how to resolve merge conflicts with this plugin(And other 5 vimcasts explaining more about Fugitive.vim).

like image 39
e3matheus Avatar answered Oct 11 '22 23:10

e3matheus