1 " Define the function we'll use. It's easier to do this than to faff about
2 " trying to run a sequence of normal mode commands.
4 " There should be four arguments:
5 " 0. The original file (tmp.xxx).
6 " 1. Their version (tmp.yyy).
7 " 2. My version (original filename).
8 " 3. The merged version (tmp.zzz).
14 let l:filename = fnameescape(fnamemodify(argv(2), ":h"))
16 " Make sure the window is big enough for diffs.
18 let &columns=(&columns * 2)
21 " Mark the buffer for the original file.
28 exe "file \[ORIG:" . l:filename . "\]"
32 " Split the buffer for my version.
40 exe "file \[YOURS:" . l:filename . "\]"
44 " Split the buffer for their version and put it below.
53 exe "file \[THEIRS:" . l:filename . "\]"
57 " Split the buffer for the merged version and put it at the side.
64 " Expand the command line window so we don't have to press RETURN later.
65 let s:cmdheight = &cmdheight
68 " Call and then discard our function.
72 " Restore the command window.
73 exe "set cmdheight=" . s:cmdheight
75 " Close the scratch buffer.
77 " Vim 7 lets us close the buffer by number. The merge is always in #4.
78 au BufWinLeave <buffer=4> qa!
80 " Prior versions can only do it by name. Fall back to a temporary file.
81 au BufWinLeave /tmp/tmp.*.* qa!