Skip to content

Use default key bindings #46

@ya2s

Description

@ya2s

I want to use vim's default keybindings (Ctrl-w + hjkl) to move between vim and tmux
So I set it as follows:

init.lua (NVIM v0.6.0-dev+bec7f47ce)

local map = vim.api.nvim_set_keymap
local map_opts = {noremap = true, silent = true}

map("", "<C-w>h", ":lua require'tmux'.move_left()<cr>", map_opts)
map("", "<C-w>j", ":lua require'tmux'.move_bottom()<cr>", map_opts)
map("", "<C-w>k", ":lua require'tmux'.move_top()<cr>", map_opts)
map("", "<C-w>l", ":lua require'tmux'.move_right()<cr>", map_opts)

tmux.conf (tmux 3.2a)

bind -n C-w switch-client -T NAVIGATOR

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind -T NAVIGATOR h if-shell "$is_vim" "send-keys C-w h"  "select-pane -L"
bind -T NAVIGATOR j if-shell "$is_vim" "send-keys C-w j"  "select-pane -D"
bind -T NAVIGATOR k if-shell "$is_vim" "send-keys C-w k"  "select-pane -U"
bind -T NAVIGATOR l if-shell "$is_vim" "send-keys C-w l"  "select-pane -R"

bind -T NAVIGATOR C-w send-keys C-w

It was possible, but it stopped responding from a certain version
What's wrong?
Could the plugin support the default key bindings as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions