Last active
March 26, 2020 21:25
-
-
Save 3coma3/a0950bc79055fb9ded6363c554e162d0 to your computer and use it in GitHub Desktop.
add a map to vim to toogle zooming a split to max width/height - moving out to a same-tab split or closing the zoomed split also restores the window layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! ToggleZoom(toggle) | |
if exists("t:restore_zoom") && (t:restore_zoom.win != winnr() || a:toggle == v:true) | |
exec t:restore_zoom.cmd | |
unlet t:restore_zoom | |
elseif a:toggle | |
let t:restore_zoom = { 'win': winnr(), 'cmd': winrestcmd() } | |
vert resize | resize | |
endif | |
endfunction | |
augroup restorezoom | |
au WinEnter * silent! :call ToggleZoom(v:false) | |
augroup END | |
nnoremap <silent> <C-\> :call ToggleZoom(v:true)<CR> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment