From c57c8f1579698a35c821904749902513bc3ba57f Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Mon, 2 Nov 2026 10:46:20 -0500 Subject: [PATCH] feat(nav): vim-aware alt+h/j/k/l resize for smart-splits.nvim --- tmux.conf | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tmux.conf b/tmux.conf index 98b093f..7f46851 100644 --- a/tmux.conf +++ b/tmux.conf @@ -33,13 +33,14 @@ bind -N "Focus pane right" -n C-M-Right select-pane -R bind -N "Focus pane up" -n C-M-Up select-pane -U bind -N "Focus pane down" -n C-M-Down select-pane -D -# ctrl+h/j/k/l: vim-aware pane navigation, the tmux half of nvim's -# config.pane_nav. In an nvim/vim/fzf pane the key is forwarded so nvim moves -# between its own splits and, at its outer edge, hands off with -# `tmux select-pane -t $TMUX_PANE`; elsewhere tmux moves directly. "Is vim" is -# smart-splits' @pane-is-vim pane option or the pane's foreground command, read -# as a format (no ps fork per keypress). Ghostty passes these keys through -# (keybind = clear); prefix + ctrl+l is the clear-screen escape hatch. +# ctrl+h/j/k/l: vim-aware pane navigation, the tmux half of smart-splits.nvim +# (nvim's config.pane_nav hands tmux panes to it). In an nvim/vim/fzf pane the +# key is forwarded so nvim moves between its own splits and, at its outer edge, +# selects the tmux pane itself; elsewhere tmux moves directly. "Is vim" is +# smart-splits' @pane-is-vim pane option or the pane's foreground command +# (vim without smart-splits, fzf), read as a format (no ps fork per keypress). +# Ghostty passes these keys through (keybind = clear); prefix + ctrl+l is the +# clear-screen escape hatch. bind -N "Focus pane left (vim-aware)" -n C-h if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-h' 'select-pane -L' bind -N "Focus pane down (vim-aware)" -n C-j if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-j' 'select-pane -D' bind -N "Focus pane up (vim-aware)" -n C-k if -F '#{||:#{@pane-is-vim},#{m/r:^(n?vim|vim|fzf)$,#{pane_current_command}}}' 'send-keys C-k' 'select-pane -U' @@ -55,6 +56,15 @@ bind -N "Resize pane down" -n C-M-S-Down resize-pane -D 5 bind -N "Resize pane up" -n C-M-S-Up resize-pane -U 5 bind -N "Resize pane right" -n C-M-S-Right resize-pane -R 5 +# alt+h/j/k/l: vim-aware resize, smart-splits' resize keys. An @pane-is-vim +# pane gets the key, so smart-splits resizes its split and, at its outer edge, +# the tmux pane; elsewhere tmux resizes by 3, smart-splits' default amount. +# Only @pane-is-vim forwards: vim/fzf without smart-splits have no resize binds. +bind -N "Resize pane left (vim-aware)" -n M-h if -F '#{@pane-is-vim}' 'send-keys M-h' 'resize-pane -L 3' +bind -N "Resize pane down (vim-aware)" -n M-j if -F '#{@pane-is-vim}' 'send-keys M-j' 'resize-pane -D 3' +bind -N "Resize pane up (vim-aware)" -n M-k if -F '#{@pane-is-vim}' 'send-keys M-k' 'resize-pane -U 3' +bind -N "Resize pane right (vim-aware)" -n M-l if -F '#{@pane-is-vim}' 'send-keys M-l' 'resize-pane -R 3' + # Window navigation bind -N "Rename window" r command-prompt -I "#W" "rename-window -- '%%'" bind -N "Create window" c new-window -c "#{pane_current_path}"