How can I maximize a split window?

VimSplitEditor

Vim Problem Overview


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?

Vim Solutions


Solution 1 - Vim

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

  1. start vim (e.g. gvim /tmp/test.cpp)

  2. invoke help :help various-motions - opens a split window

  3. move help into separate tab maximized: C-wT

  4. enjoy reading the fine manual :)

  5. 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 - Vim

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 - Vim

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 - Vim

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 - Vim

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.

Solution 6 - Vim

You can get help window in full size without closing/resizing any other windows by using

tab help {topic}

This will open help window in a new tab, other windows will be left as-is (really resized so that tabline can be shown, but this is only one additional line above). You can close help as usual: at least :bw<CR> and <C-w>c work for me closing new tab as well.

Solution 7 - Vim

Install the plugin vim-maximizer, then you can maximize the current window and restore with F3

Solution 8 - Vim

Plugin ZoomWin

by Charles Campbell

This plugin remaps

> Ctrl-w o

to do both: maximize and restore previous layout.

This plugin can be downloaded from two locations

Solution 9 - Vim

Somehow the ZoomWin plugin did not work at all for me, I now see there are other plugins but I already wrote this and gives me the exact effect I wanted (with a minor quirk detailed below):

function! ToggleZoom(zoom)
  if exists("t:restore_zoom") && (a:zoom == v:true || t:restore_zoom.win != winnr())
      exec t:restore_zoom.cmd
      unlet t:restore_zoom
  elseif a:zoom
      let t:restore_zoom = { 'win': winnr(), 'cmd': winrestcmd() }
      exec "normal \<C-W>\|\<C-W>_"
  endif
endfunction

augroup restorezoom
    au WinEnter * silent! :call ToggleZoom(v:false)
augroup END
nnoremap <silent> <Leader>+ :call ToggleZoom(v:true)<CR>

Use the mapped key (Leader and + in my case) to toggle between maximized / previous layout. If you change to another split in the same tab, maximization turns off.

If you change tabs, the split stays maximized, although somehow it won't cover the complete full width anymore, with the width minimized windows gaining back some 4 columns or something. Anyway it works acceptably for me even with that minor quirk.

edit: somehow it works fine now, must've messed up in some way before.

Solution 10 - Vim

To get just the help up, then close the other window, do this: :helpCTRL-WCTRL-W:close. Then you'll have just the help up.

Solution 11 - Vim

in your .vimrc, just place

nmap - :res<CR>:vertical res<CR>$

When you want maximize current window, just press - in command mode. Press = when you want to restore the last status of multiple window

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshiblyView Question on Stackoverflow
Solution 1 - VimseheView Answer on Stackoverflow
Solution 2 - VimRookView Answer on Stackoverflow
Solution 3 - VimGreg HewgillView Answer on Stackoverflow
Solution 4 - VimAzrael3000View Answer on Stackoverflow
Solution 5 - VimGustavo MatiasView Answer on Stackoverflow
Solution 6 - VimZyXView Answer on Stackoverflow
Solution 7 - VimSeareneView Answer on Stackoverflow
Solution 8 - VimHotschkeView Answer on Stackoverflow
Solution 9 - VimataView Answer on Stackoverflow
Solution 10 - VimJeff FerlandView Answer on Stackoverflow
Solution 11 - VimblessdybView Answer on Stackoverflow