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?
3 Answers
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.
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 =
.
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>
-
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.– leeand00Feb 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 SFeb 22, 2019 at 16:59 -
1Oh I understand, sorry AS I asked this question such a long time ago...– leeand00Feb 22, 2019 at 17:07
tabedit %
as an approximation.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 asctrl-w o
. At least you can close(minimize) withctrl-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.nnoremap <C-w>t :tabsplit
for zooming in and<c-w>q
for zooming out, or zooming in/out experience I should say.