Skip to content

Can not navigate between tmux panes when in vim insert mode #106

@HaomingFu

Description

@HaomingFu

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

image

Versions

Tmux 3.3a
tmux.nvim commit 673782b (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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions