Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,26 @@ bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane
bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' {} { select-pane -R }
```

##### A note on the zoomed state

When wrapping is disabled and in zoomed state, navigation between tmux panes
using `C-h,j,k,l` is not possible using the configuration above, as
`#{pane_at_*}` are all `1` in zoomed state (they reflect the visible window
layout, see `window_layout` vs `window_visible_layout` in `man tmux`).

One workaround is to replace the conditions `#{pane_at_*}` above with:
```
#{e|-:#{pane_at_*},#{window_zoomed_flag}}
```

This will essentially disable the no-wrapping behavior when zoomed, resulting
in unwrapped navigation (but a working one).

The same workaround can be enabled for vim using:
```vim
let g:tmux_navigator_no_wrap_disable_when_zoomed = 1
```

#### Nesting
If you like to nest your tmux sessions, this plugin is not going to work
properly. It probably never will, as it would require detecting when Tmux would
Expand Down
10 changes: 9 additions & 1 deletion plugin/tmux_navigator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ if !exists("g:tmux_navigator_no_wrap")
let g:tmux_navigator_no_wrap = 0
endif

if !exists("g:tmux_navigator_no_wrap_disable_when_zoomed")
let g:tmux_navigator_no_wrap_disable_when_zoomed = 0
endif

let s:pane_position_from_direction = {'h': 'left', 'j': 'bottom', 'k': 'top', 'l': 'right'}

function! s:TmuxOrTmateExecutable()
Expand Down Expand Up @@ -145,7 +149,11 @@ function! s:TmuxAwareNavigate(direction)
let l:args .= ' -Z'
endif
if g:tmux_navigator_no_wrap == 1 && a:direction != 'p'
let args = 'if -F "#{pane_at_' . s:pane_position_from_direction[a:direction] . '}" "" "' . args . '"'
let condition = '#{pane_at_' . s:pane_position_from_direction[a:direction] . '}'
if g:tmux_navigator_no_wrap_disable_when_zoomed
let condition = '#{e|-:' . condition . ',#{window_zoomed_flag}}'
endif
let args = 'if -F "' . condition . '" "" "' . args . '"'
endif
silent call s:TmuxCommand(args)
if s:NeedsVitalityRedraw()
Expand Down