Open multiple vim tabs and windows simultaneously from command line

2

2

I've got four files a b c d and would like to open them all in vim such that I have two tabs each vertically splitted into two windows; files a and b in the first tab and c and d in the second tab. Can I do this from command line?

I know there are -p and -O parameters, but they don't seem to cooperate. One only overwrites another from what I observed...

Sventimir

Posted 2014-05-25T08:22:35.147

Reputation: 123

Answers

2

This command does what you want:

$ vim -c "edit a|split b|tabedit c|split d"

or, with shortened commands:

$ vim -c "e a|sp b|tabe c|sp d"

romainl

Posted 2014-05-25T08:22:35.147

Reputation: 19 227

That's what I was looking for. Thank you very much. :) – Sventimir – 2014-05-26T07:30:29.540

2

You should be able to open your files vertically splitted like this:

vim -O fileA.txt fileB.txt
vim -O fileC.txt fileD.txt

There are also some keys you can use for splitting.
Ctrl-W s for horizontal splitting
Ctrl-W v for vertical splitting
Ctrl-W q to close one

But you should know that different Vim instances have independent sessions.
Currently vim does not support to have seperate toplevel’ windows for the same process/session. It's on the ToDo list. (See :help todo and search for "top-level".)

Perhaps the following will brings you further, if you need to share the same buffer between multiple instances of vim: gnu screen - Working with vim on multiple monitors

MrMAG

Posted 2014-05-25T08:22:35.147

Reputation: 201