3

I use a set of tabs and splits in my Vim window for my workflow.

My setup looks something like this:

1st tab with a vertical split showing two buffers. 2nd tab in the following split:

-----------------------------------
|                    |            |
|                    |            |
|                    | Buffer b   |
|                    |            |
|                    |            |
|  Buffer a          |------------|
|                    |            |
|                    |            |
|                    | Buffer c   |
|                    |            |
|--------------------|------------|

Now, how can I start vim such that I get all my files loaded as separate buffers in the about layout? I am too lazy to set up this layout everytime I have to restart my vim for some reason.

2
  • You also seem to be too lazy to at least look up the excellent Vim help and post your attempts with your question. Mar 10, 2014 at 12:26
  • Ingo Karkat: Not really. I tried, but couldn't find anything about such a feature on Vim help.
    – darnir
    Mar 10, 2014 at 12:36

2 Answers 2

3

Vim supports the -o and -O arguments to influence the split behavior of passed files. Since only one can be specified, and you want an asymmetic layout, you need to adapt this later, with commands that you can pass via -c {Ex-cmd}.

For your second, more interesting layout, one simple way is to start with horizontal splits, and move the first (buffer a) window to the left with <C-w>H.

$ vim -o -c "wincmd H" a b c

I'll leave the addition of the first tab layout as an exercise to you...

Alternative

If the set of files is fixed (and the layout more complex), Vim sessions (cp. :help Session) store the window layout and set of opened files.

3
  • Yes! Your alternative sounds good. And since my set of files is pretty much fixed, I can use sessions. I didn't know about this feature at all! Thanks a lot! (I'll mark this answer, as soon as I get the sessions working)
    – darnir
    Mar 10, 2014 at 12:37
  • Though everything is built-in, I can recommend the session.vim plugin, which simplifies the session handling. Mar 10, 2014 at 13:40
  • Tim Pope's vim-obsession and the extension vim-prosession are also amazing plugins extending the :mksession option with sane and fantastic capabilities.
    – dragon788
    May 15, 2018 at 17:03
0

You can also use the vim-layout script that uses the -o, -c arguments automatically and supports different layouts. To get the output you wanted you would simply run:

vl <the three files>

Disclaimer: I wrote the script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .