This is doable without any shell shenanigans by setting all the diffy options globally (along with some autocommands, because vim gets angry if you try to diff more than 8 files at once)
vim -c 'windo set diff scrollbind cursorbind scrollopt+=hor nowrap foldmethod=diff foldcolumn=2 | au BufWinEnter * setlocal diff | au BufWinLeave * setlocal nodiff' -O2 your filenames here
This will open all your files in buffers, and vertically split vim into two windows (use -o2
if you want horizontal), and always be in diff mode, even if you switch between buffers or open new files.
If you're merging all your files together into one super-file, then using :bn
will be fine for getting around.
If you're merging pairs of files, then you'll want some variation of :windo bn N
, where N depends on how you listed your files:
- For
A1 A2 B1 B2 C1 C2
, :windo bn 2
will do the right thing
- For
A1 B1 C1 A2 B2 C2
, you'll need to initially go to the A2
buffer, and then :windo bn 1
will do the right thing
I pulled the settings from the help file:
In each of the edited files these options are set:
'diff' on
'scrollbind' on
'cursorbind' on
'scrollopt' includes "hor"
'wrap' off
'foldmethod' "diff"
'foldcolumn' value from 'diffopt', default is 2
These options are set local to the window. When editing another file they are reset to the global value.
And only discovered the need for the autocommand nonsense empirically.