The "ugly" 4 window view of the default
vimdiff configuration can scare you out even if you were using Vim for a while. It's just too much information for most of the common merge cases.
How to configure vim or nvim with git to get a comfortable mergetool experience?
Not 4 windows...
Install vim-fugitive and use following configuration in your
[mergetool "nvim"] cmd = nvim -f -c \"Gdiff\" \"$MERGED\"
It will give you a "nice" view with 3 windows horizontally splitted.
On the left side you have a current working copy (LOCAL).
On the right side you can view the remote (merged) file (REMOTE).
The central part of your screen shows a result (MERGED).
What is good about that setup (and why I use it all the time)?
- In Vim normal mode place the cursor inside a right window in a merge conflict section (it is marked with a violet/pink highlight).
- Hit the keys dp (a shortcut from
- Code under the cursor will replace conflicted part in the MERGED file.
- Conflict solved, you are good to go.
Repeat above steps for all merge conflicts (if you have more of them). You can navigate between left (LOCAL) and right (REMOTE) windows making diffputs to MERGED file as well as making manual changes directly inside merged content.
You may execute
:Gwq command in any of the opened windows. The window where you execute that command will be commited and marked as a merge resolution. It is very useful if you want to use just REMOTE or just LOCAL version without any further merge resolution steps.
When in the central window use
d3o to pull changes from LOCAL or REMOTE file.