Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
The zoomwin plugin does this. –  Stabledog Aug 2 at 13:56

3 Answers 3

up vote 3 down vote accepted

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).

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
    
Check for being a neat hack to implement. –  James Andino Sep 24 '11 at 2:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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