开发者

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 bot开发者_运维知识库tom.


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜