6

In tmux if you have alot of panes open, you can press CTRL+B, z to zoom into that terminal pane. Is there a way to do the same thing in vim, to zoom into / out of the selected pane?

6
  • 5
    AFAIK, there are some plugins that simulate this, but nothing native to vim that i can think of. You could try tabedit % as an approximation.
    – D. Ben Knoble
    Oct 27, 2018 at 19:29
  • 3
    One of the plugins is zoomwin which remaps ctrl-w o which IMHO is a good choice. However, I would recommend to use the suggestion of @D.BenKnoble (one less plugin and works everywhere). I agree that :tabe % is not as short as ctrl-w o. At least you can close(minimize) with ctrl-w c since it is the only window in this tab. Just for completeness: since tabs in vim are different to tabs in gui apps, I'd recommend for those who are not familar with this to read stackoverflow.com/a/103590/1057593.
    – Hotschke
    Oct 28, 2018 at 8:53
  • I use nnoremap <C-w>t :tabsplit for zooming in and <c-w>q for zooming out, or zooming in/out experience I should say.
    – 3N4N
    Feb 22, 2019 at 4:15
  • 1
    redd.it/979lv2
    – A S
    Feb 22, 2019 at 5:51
  • @AS If you want to post that as the answer I think it's great!
    – leeand00
    Feb 22, 2019 at 7:01

3 Answers 3

4

I use ctrl-w | if my screen is split vertically or ctrl-w _ if split horizontally to zoom in. To get back, I use ctrl-w =.

3

A nice way to do this is with :tab split

This will open the current buffer in a new tab where it is "zoomed".

When you are done use :q to close the tab and you are back to the previous window layout.

1

All the credits go to reddit user tLaw101:

function! WinZoomToggle() abort
    if ! exists('w:WinZoomIsZoomed') 
        let w:WinZoomIsZoomed = 0
    endif
    if w:WinZoomIsZoomed == 0
        let w:WinZoomOldWidth = winwidth(0)
        let w:WinZoomOldHeight = winheight(0)
        wincmd _
        wincmd |
        let w:WinZoomIsZoomed = 1
    elseif w:WinZoomIsZoomed == 1
        execute "resize " . w:WinZoomOldHeight
        execute "vertical resize " . w:WinZoomOldWidth
        let w:WinZoomIsZoomed = 0
    endif
endfunction

nnoremap <leader>wz :call WinZoomToggle()<CR>
3
  • that's isn't what I was talking about...I was talking about the :tabedit % and :tabclose answer is much better than that one, as there isn't ready anything to setup apart from maybe a keymap, it's on that page if you keep reading a bit further.
    – leeand00
    Feb 22, 2019 at 15:14
  • It may be much better but it's not similar in any way to tmux's <C-b>z :). While the function from the original post indeed replicates it.
    – A S
    Feb 22, 2019 at 16:59
  • 1
    Oh I understand, sorry AS I asked this question such a long time ago...
    – leeand00
    Feb 22, 2019 at 17:07

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.