I recently tried out the fantastic
vim-tmux-navigator tmux plugin.
Unfortunately, some the default key bindings conflict with some of the key bindings my fuzzy finder of choice uses.
I wanted to remap them to the default vim split navigation commands that are prefixed with
C-w, and found the solution of
hjdivad in his gist. However, I wanted a simpler solution, so after
some more digging I stumbled upon this reddit post
and ultimately came up with the following solution, which doesn't rely on key bindings that unbind themselves, but uses tmux's
In vim, I still use the
but I overrode the default mappings and configured my own as seen in the
In tmux, instead of using
vim-tmux-navigator, I also defined my own key bindings as seen in the
I re-used the check to find out if we're in vim from the plugin.
The crux is the first
bind-key, where we map
C-w to switch the client key-table to switch-pane.
This is an arbitrarily chosen name. Below that, we define new key bindings in that key-table, by adding the
followed by the name of the key-table, here switch-pane. The rest is similar to how the plugin does it:
we check if we're in vim, if yes, we send the mapping we defined in the
if not, we execute the appropriate tmux's
I wasn't able to confirm this 100%, but my solution should work with tmux v1.6+. It works for sure in tmux v2.5, which is the version I'm currently running.
Add the following to your tmux status line to display the active key-table unless it's the default