user17925
user17925

Reputation: 1019

Mixing vertical and horizontal splits in vim, from command line

Title really says it all. There is the -O option for opening splits vertically, and -o for horizontally, but trying to mix them doesn't seem to work.

My goal is to use g/vimdiff for 3-way file merging in mercurial in a way more like kdiff3 does. This method would have the 3 files to be merged split into 3 vertical tabs across the top (my local version, the other version of the file I am merging it with, and the base version between the two), while the "output", or results of the merge, is a large horizontal tab stretched across the bottom.

Upvotes: 2

Views: 1436

Answers (2)

Cascabel
Cascabel

Reputation: 497562

This is a little kludgy, but it works:

vim -c "wincmd J" -O base diff1 diff2

(That's a verbatim control-W there)

Maybe there's a more elegant method, but this simply loads all of them as vertical and then moves the active (first) one to the bottom.

Upvotes: 2

jamessan
jamessan

Reputation: 42757

Although Vim allows you to supply more than 2 files to be diffed, it doesn't particularly work very well for doing more than a 2-way diff.

At any rate, you're correct that you can't specify different ways to split using both -O and -o. The best you'll get is either sourcing a script to run (via -S 3way.vim) or using --cmd arguments to setup the splits and change which buffers are displayed in those splits.

A potential 3way.vim, assuming you invoke vim as vim -S 3way.vim localfile otherversion baseversion merged would be

botright vsplit +b2  " Opens a split and focuses otherversion
botright vsplit +b3  " Opens a split and focuses baseversion
botright split +b4   " Opens a split and focuses merged
wincmd =             " Resize all windows so they share space equally

Upvotes: 1

Related Questions