I'm trying to set up git mergetool to spawn vimdiff with the following splits (and a configuration customized to each split):
Splits from the following buffers $LOCAL, $BASE, $REMOTE, & $MERGED (horizontal)[done]- Show line-numbers per split [Todo]
- Display only the name of the buffer variable in these three splits: $LOCAL, $BASE, $REMOTE. [Todo]
The $MERGED split statusline should show the filename from%t[the $MERGED split is done]
I used this git configuration in my local repo:
git config merge.tool vimdiff
git config mergetool.vimdiff.cmd 'vim +"set number" +"set statusline=%t" -d -c "wincmd J" -O $MERGED $BASE $REMOTE $LOCAL'
git config merge.conflictstyle diff3
git config mergetool.prompt false
- In the configuration above, a status line substring should be displayed per-split but I can't find the right way to build a regex to reduce the filename in the statusline down to just one of the three desired buffer variable names (i.e. "BASE", "REMOTE", or "LOCAL"). A regex isn't required, but it seems like a promising option.
- Line numbers are only showing up in one split, but I want them in all four.
After much googling and many experiments, I still can't coerce vimdiff into showing the status line / numbers I want... I am not using a statusline plugin such as vim-powerline. How do I configure my git options to spawn vimdiff the way I need?
I included a screen capture of my existing git mergetool splits.

Adding line numbers for every split
In this command,
vim +"set number" ... -O $MERGED $BASE $REMOTE $LOCAL, looks like vim intenally first creates the splits and then executes the set option. Refer: vim -c option.There are 2 options to overcome this.
--cmdoption: If we use,vim --cmd "set number" -O $MERGED $BASE $REMOTE $LOCAL,set numberis applied before creating the splits. In fact, it is applied even before reading the .vimrc file. (Refer: vim --cmd option). It might cause concern if we have a overriding config in .vimrc likeset nonumber.-Ooption, we can manually create the splits. This way after the-coption is applied, the splits will be created. We will send the file parameters in the reverse order as below: But now we need another option (diff this) to enablediffin all splits, since-donly applies to the files passed directly in the command line.Modifying the status line
Rather than regex, using static strings looks a more reliable option. We can leverage vim
setlocaloptions to acheive this. So the total command will beGit mergetool config:
git mergetooloutput:Update 1
If it is ok to retain the existing status line or do a simple append of the buffer number of the split, then
-Svim option can be used to greatly simplify the command..git_merge_vimrccontents:Note: vim scripts can be used in the source file to print complex status line if that is required.