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.
27 exe "file \[ORIG:" . l:filename . "\]"
31 " Split the buffer for my version.
38 exe "file \[YOURS:" . l:filename . "\]"
42 " Split the buffer for their version and put it below.
51 exe "file \[THEIRS:" . l:filename . "\]"
55 " Split the buffer for the merged version and put it at the side.
67 " Expand the command line window so we don't have to press RETURN later.
68 let s:cmdheight = &cmdheight
71 " Call and then discard our function.
75 " Restore the command window.
76 exe "set cmdheight=" . s:cmdheight
78 " Close the scratch buffer.
80 " Vim 7 lets us close the buffer by number. The merge is always in #4.
81 au BufWinLeave <buffer=4> qa!
83 " Prior versions can only do it by name. Fall back to a temporary file.
84 au BufWinLeave /tmp/tmp.*.* qa!