The vs-code
has an amazing feature to solve merge conflicts as shown in the image..
We can easily select current
,incoming
or both
the changes..
but in case of vim
we have to manually do it which becomes problematic when file size is large...is there any nice way to do this in vim?
There are a couple of things that are not clear in your question:
Anyway, here is how a basic merge conflict resolution looks after:
$ git mergetool --tool vimdiff
Usage is pretty simple:
]c
, and [c
for the previous change,:diffget LOCAL
(or :diffg L
for short),:diffg B
,:diffg R
,If you still find it too "manual" you can simply make your own mapping:
" choose LOCAL
nnoremap <Left> :diffget LOCAL<Bar>diffupdate<CR>
" choose REMOTE
nnoremap <Right> :diffget REMOTE<Bar>diffupdate<CR>
" choose BASE
nnoremap <Up> :diffget BASE<Bar>diffupdate<CR>
" choose both
nnoremap <Down> :/>>>>>>>/;?<<<<<<<?,.g/^\(<<<<<<<\\|=======\\|>>>>>>>\)/d<CR>
My ConflictMotions plugin has motions to go to the next conflict [marker] (]x
, ]=
), corresponding text objects, and also a :ConflictTake
command that lets you resolve the conflict by choosing some of the parts ([none this ours base theirs both all range query]
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With