I have installed vim-tmux-navigator on the tmux and the vim side and I can navigate between vim panes and tmux windows using Ctrl-[hjkl]
BUT: This means that readline (or bash?) shortcuts are overwritten, e.g. Ctrl-k
(delete to end-of-line), which I want to use.
All my attempts to remap keys to require the the tmux-prefix, e.g. Ctrl-b [hjkl]
vim-tmux-navigator have failed.
Does anyone have a solution for this?
Note: I am using C-b as an example, for which there is a good solution below. I have been using C-Space wich complicates things a little.
Best Answer
Yes, it's possible to remap the keybindings in order to use
<C-b>
(your tmux prefix) followed by[hjkl]
to change panes, and\
to go to the previous pane.Note that you need to configure that both in Vim and in tmux.
This is the Vim configuration for those keybindings:
Add those lines to your
.vimrc
.And in your
.tmux.conf
, use the snippet (not the TPM) to configure it, then change the main bindings to:(In short, remove the
C-
part, and also the-n
which makes them run without a prefix. Then update thesend-keys
to send the keys Vim is expecting, which are the same ones, with the prefix.)You might want to update the
copy-mode-vi
keybindings too, though it's unclear which keys you would like to use there, since there's no "prefix" enabled in that mode... You might want to think about that one.