If I had x or more windows open in a VIM session and I wanted to quickly hide all but the active one for a moment then return the windows to the layout I had them int how would I do it?

  • The zoomwin plugin does this. – Stabledog Aug 2 '14 at 13:56

In Vim 7 and later, you can use a “tab page” for this (i.e. “GUI-style” tab). You can use the :tab command with either :split or :sbuffer:

:tab split
:tab sp      " shorter version

:tab sbuffer
:tab sb      " shorter version

Both split and sbuffer do nearly the same thing when used without additional arguments (split the current buffer). You will probably want to use split if you anticipate wanting to load some (possibly not-already loaded) pathname (split path/to/some/file; although you could just use :tabe instead since this is in the context of opening a new tab); sbuffer makes it easier to switch to an existing buffer (sb {bufnum} or sb {bufname}).

Once you have your new tab open, you can use gT and gt to switch between the resulting tabs (or the GUI controls if you are using a GUI version of Vim). When you are finished with your single-window tab, just :q to close the window (and thus the tab) and return to your original tab (with its original window layout), or use :tabclose (:tabc), or switch back to your original tab and use :tabonly (:tabo).


I use CTRL-W _ to horizontally "push" the other windows out of the way making the current window the expand to the largest available area. Use CTRL-W | to do the same vertically. I'm sure there's probably a way to do both at once, but I haven't noticed or looked for it. Look in :help CTRL-W

To restore them do CTRL-W =. One caveat though is they aren't restored to their original configuration. CTRL-W = actually re-calculates the best fit for all the windows in the screen.

  • Check for being a neat hack to implement. – Arcabard Sep 24 '11 at 2:22

As far as I know, there is no way to simply switch between two different window layouts, but you can hide all other windows by issuing the command :only (or :on). See the Vim help for this command.

  • 1
    Its not possible go back to the previous layout with this. Chris Johnsen's answer lets us do that as well. – Phani Oct 8 '14 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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