Yev Orlov

How to zoom in and out of the active pane in vim / neovim

Because I prefer working with splits over tabs, I like how tmux allows you to easily expand/collapse the active pane by pressing <prefix>+z. There are a few ways to achieve this in (neo)vim, some more sophisticated than others. I prefer configs I can read easily though.

The easiest implementation I found is, ironically, to open the current buffer in a new tab. Essentially this means that whatever split configuration you've had stays untouched on the first tab while the last active buffer opens fullscreen on the second one. To "zoom out" you simply close the tab, which brings you back to exactly where you were.

nnoremap <leader>zi :tab split<cr>
nnoremap <leader>zo :tab close<cr>

or the modern way (neovim + lua):

vim.keymap.set("n", "<leader>zi", ":tab split", {})
vim.keymap.set("n", "<leader>zo", ":tab close", {})

This approach won't scale very well if you happen to use tabs for other things, but for my workflow it's perfect.