It is possible to convert all windows into different split mode while editing? Instead of one by one?

In example (having multiple windows) from horizontal to vertical split and opposite, or from tab split all files into horizontal/vertical view and back?

Similar as it works at start when opening multiple files with -p, -o, or -O?

  • 2
    Now that you have answerd the question yourself I'm pretty confused about what you're asking. From the question I understand you are asking how to rearrange opened windows in a different layout but from your answer I understand you want to close all the opened windows but one, and to open all listed buffers in splitted windows.
    – toro2k
    Commented Feb 16, 2015 at 12:54
  • 1
    @toro2k I've opened multiple files using -p, -o, -O which appear in different split layouts, but I'd like to know how to switch between different layouts while I'm editing them (in the editor, without quitting and re-opening files again).
    – kenorb
    Commented Feb 16, 2015 at 13:03

4 Answers 4


You could accomplish something like this using the argument list. The general idea is to collect all of the open windows into the argument list, then close all the splits, then use the argument list to open everything in a new way.

First, clear the argument list, in case it's already populated.

:argdelete *

Next, collect all the windows into the argument list.

:tabdo windo argadd %
  • :tabdo performs a command on each tab, visiting one at a time
  • :windo does the same in each window of the current tabpage
  • :argadd % adds the current buffer to the argument list

Now we have all of the windows in the argument list. Let's close all but one window.

:tabonly | only
  • :tabonly closes all tab pages except the current one
  • :only closes all windows except the current window in the current tab page

Flip to the first argument.


Now we'll cycle through all of our arguments and open them in the style of our choosing.

:argdo tabedit %

Change tabedit to split or vsplit as desired.

NOTE: I haven't figured out why yet, but this duplicates the last window. We can just close it with :quit (or :q for short).


  • This clobbers your argument list, if you had one
  • If you have 'equalalways' turned off (i.e. :set noequalalways) and you're using this for opening windows in splits, you may quickly run out of screen space before opening all the windows

To convert all splits into horizontal splits, you can do:

:windo wincmd K

For vertical splits:

:windo wincmd H

How this works: windo means 'do the following command for all windows'. wincmd H/K is the same as if you pressed <C-W> H/K:

CTRL-W H        Move the current window to be at the far left, using the
                full height of the screen.  This works like closing the
                current window and then creating another one with
                ":vert topleft split", except that the current window contents
                is used for the new window.

Using :wincmd J/L appears to create an infinite loop, unfortunately. Note that this may change the order of your splits to something unexpected. You can switch two windows' positions with <C-W> X after running the command if you'd like.

If you like having a lot of splits open and sometimes find yourself running low on screen real estate, you may be interested in my accordion plugin.


To close all splits but current windows, use: :on (:only), or use the shortcut Ctrl+(w,o).

:on[ly][!] Make the current window the only one on the screen. All other windows are closed.

To split all the buffers again, use: :ba to split horizontally or :vert ba to split vertically.

:[N]ba[ll] [N] :[N]sba[ll] [N] Rearrange the screen to open one window for each buffer in the buffer list.

:vert[ical] {cmd} Execute {cmd}. If it contains a command that splits a window, it will be split vertically.

To quit: :qa (See: How to exit vim from split mode?).



It's easiest to use buffers as the "intermediate" layout.

  • buffers > horizontal windows: :ba (buffer all)
  • buffers > vertical windows: :vert ba (vertical buffer all)
  • buffers > tabs: :tab ba (tab buffer all)
  • windows > buffers: :on, :only (current window only)
  • tabs > buffers: :tabo, :tabonly (current tab only)

So if you want to convert all windows to tabs, first convert windows to buffers, then buffers to tabs:

:on | tab ba

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.