I'm trying to open 3 files in vim from the command line. I'd like one file on the left with a vertical split between it and the other two files, the remaining two files would be horizontally split.
| 2
1 |---
| 3
I know I can use the command vim -O Notes.markdown -O Plan.markdown
to open the first two files in a vertical split and once I'm in I can switch to the second file with ctl w
and then use the command split History.markdown
to achieve what I want, but I'd like to be able to do it all in one line from the command line.
I tried using the command vim -O Notes.markdown -O Plan.markdown -c split History.Markdown
which gets close, but it splits the first and second file leaving the 3rd on the right side of the vertical split.
The thing I can't figure out is if I can tell vim to use the ctl
key from the command line so I could run something like ... -c <switchwindowcommand> | split History.markdown
. Is there a way to specify the control key?
There are many ways to do this; the key is :wincmd
, which lets you execute arbitrary window commands.
Here, I first create three vertical splits, and then use <C-W>H
to move the first window to a full-height vertical split on the left:
$ vim -o 1 2 3 -c "wincmd H"
I think this is what you're looking for.
:help windcmd
For example:
vim a.txt -c "vs b.txt | sp c.txt" -c "wincmd h"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With