How can I maximize a split window?
Invoking :help
in Vim, I got the help manual page with split window. I want to maximize the help manual window and close the other window.
How can I do this? What is the Vim command to do this?
Solution 1:
You can employ Ctrl+WT (that's a capital T
) to move any open window to its own tab.
As mentioned by others Ctrl+W_ / Ctrl+W| to maximize within the current tab/window layout (while respecting min height/width settings for various other windows).
(Ctrl+W= resizes all windows to equal size, respecting the minimum height/width settings)
Edit To the comment
- start vim (e.g.
gvim /tmp/test.cpp
) - invoke help
:help various-motions
- opens a split window - move help into separate tab maximized: C-wT
- enjoy reading the fine manual :)
-
move the help back into the original tab:
mAZZ<C-w>S`A
- mA: set global mark A
- ZZ: close help buffer/tab
- C-wS: split original window
- `A: jump to saved mark A
You can avoid using a mark for normal (non-help) buffers. Let me know if you're interested.
Solution 2:
With :help [topic] you open up a topic that interests you.
Ctrl-Wo will minimize the other windows (leaving only the help window open/maximized).
(Ctrl-Wo means holding Ctrl press W, and then o)
Solution 3:
You can expand a window to its maximum size using Ctrl+W_ (underscore). The final size of the expanded window will be constrained by the value of the winminheight
option. When you close the help window, your previous window(s) will be restored to their former sizes.
Solution 4:
I prefer to use tabs for that. Use
:tabedit %
to open a file maximized in a new tab, once you are done return to the old setup with all windows using
:tabclose
I find this the ideal solution as this works together with :cw
and the Tagbar plugin. Taken from: vim.wikia
Solution 5:
I like to use 'M' to maximize and 'm' to minimize.
It won't look great as it'll shrink all the other open windows that are in the same buffer, but I found it to be more useful when dealing with tabs. So for instance, instead of opening a new tab for that file then having to close it after you're done with it or want to minimize it.
nnoremap <C-W>M <C-W>\| <C-W>_
nnoremap <C-W>m <C-W>=
The reason for nnoremap is that I don't care about recursive mapping, but just map should also work.