Suppose I open multiple files in vim like this:

vim a.cc b.cc x.cc

vim will open all files, but show only one at a time, the rest being accessible using the :next command.

After having these files opened, how to spread them into a split view, like if I had used the -O flag when opening them? Also, it would be nice to know how can I spread them into tabs too.

1 Answer 1


Here are a bunch of helpful commands for you:

To open every buffer in a horizontal split:


To open every buffer in a vertical split:

:vert sball

You can do the same thing with tabs, e.g, to open every buffer into its own tab:

:bufdo tab split

If you would like more control over how they get split, you can do this individually.

First, list every open buffer with:


Then you can choose what to do for each buffer.

To open buffer N in a horizontal split:

:sb N

sb is an abbreviation of :sbuffer

To open buffer N in a vertical split:

:vert sb N

To open buffer N in a new tab:

:tabedit | bN
  • 1
    Don't forget about :sball. :)
    – Tumbler41
    Aug 26, 2016 at 20:29
  • From your answer and the comment above, I could derive what I actually wanted: :vert sball. Thanks folks.
    – Kira
    Aug 26, 2016 at 20:32
  • @Kira I was actually just about to add that into my answer, but still I'm glad that I could help!
    – DJMcMayhem
    Aug 26, 2016 at 20:33
  • BTW, I feel :bufdo tab split does not quite do what you intend to do. If you open files like vim a b c, then run that command, you will end up with 4 open files, a b c c. IDK why though, but I tested it here.
    – Kira
    Aug 26, 2016 at 20:36
  • @Kira You're right, I'm not sure what causes that. You could do :exe "bufdo tab split" | q, but that seems kinda hacky.
    – DJMcMayhem
    Aug 26, 2016 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.