Can not navigate between tmux panes when in vim insert mode
Problem
Say I open multiple Tmux panes, the pane under focus is running Neovim in insert mode. I am not able to navigate to other panes using keyboard shortcuts. I have to switch to normal mode in Neovim and only then can I navigate from the pane running Neovim to another pane.
Expected behavior
With proper settings, I hope that I can navigate between Tmux panes freely using keyboard shortcuts, even when the pane is running Neovim/Vim in insert mode.
Screenshots
Versions
Tmux 3.3a tmux.nvim commit 673782b74a6055d430d3f5148a033edd99e5519f (2023 Sept 6)
My settings
Tmux settings:
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }
bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'
Neovim settings:
local status_ok, tmux = pcall(require, "tmux")
if not status_ok then
return
end
tmux.setup {
navigation = {
cycle_navigation = false,
enable_default_keybindings = true,
persist_zoom = false,
},
resize = {
enable_default_keybindings = false,
},
}
Question
Is there any way in which I can navigate between Tmux panes freely using keyboard shortcuts, even when the pane is running Neovim/Vim in insert mode? If so, how? Thanks!
Heho,
this must get implemented. Feel free to file a pr.
https://github.com/aserowy/tmux.nvim/blob/ea67d59721eb7e12144ce2963452e869bfd60526/lua/tmux/navigation/init.lua#L8
Here would be the line. Maybe you can extend options to specify which scopes should get bound with n as default.
Kind regards Alexander