0
votes

I use the tmux terminal multiplexer and I have this simple layout:

enter image description here

I have a Vim pane for code editing and a terminal for building and searching the code and other stuff.

As you may know when I'm in Vim pane I can press Ctrl+BZ to zoom the Vim pane and press it again to zoom back to the original layout.

Now I want to know whether it's possible to bind Esc in Vim's Normal mode to send Ctrl+BZ to zoom the Vim pane?

Something like other IDEs that pressing Esc will hide everything except the code editor?

1
@Marth Yeah, You are right, but it's ok. Pressing Esc will toggle zoom state of the panes. - s4eed

1 Answers

1
votes

You can use :!<cmd> from vim to pass <cmd> to the shell, so:

:!tmux resize-pane -Z

will toogle the zoomed state of vim's pane.
Then you just have to remap Esc:

:nnoremap <Esc> :!tmux resize-pane -Z<CR><Esc> 

This however will toogle the zoomed state every time you press Esc (hence actually revealing other panes half the time).

I'm guessing you want vim to stay maximize, so (credits to this post for identifying if a pane is zoomed):

:nnoremap <Esc> :silent! exec "!if \\! tmux list-panes -F '\\#F' \\| grep -q Z; then tmux resize-pane -Z; fi"<CR>:redraw!<CR><Esc>