Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim-Tmux-Navigator with Tmux only loophole 'C-h' #286

Open
javijjavi opened this issue Nov 8, 2020 · 5 comments
Open

Vim-Tmux-Navigator with Tmux only loophole 'C-h' #286

javijjavi opened this issue Nov 8, 2020 · 5 comments

Comments

@javijjavi
Copy link

Hi everyone,

First of all, thank you for helping me.
The issue is when I'm using vim tmux navigator with a session in tmux, I can use all the commands of vim tmux navigator, except the command Crtl + h.

Vim version 8.2.1913

Tmux version 3.1b

ZSH 5.8

TmuxNavigatorProccessList-

  • S zsh
  • S vim
  • S tmux: client

.tmux.conf.local-
[...]

# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
    "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l

vimrc-

runtime! debian.vim
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif
set number
set mouse=a
set numberwidth=1
set clipboard=unnamed
syntax enable
set showcmd
set ruler
set encoding=utf-8
set showmatch
set sw=2
set relativenumber
set laststatus=2
set cursorline
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'easymotion/vim-easymotion'
Plug 'scrooloose/nerdtree'
Plug 'christoomey/vim-tmux-navigator'
call plug#end()
colorscheme gruvbox
let g:gruvbox_contrast_dark = "hard"
let mapleader=" "
let NERDTreeQuitOnOpen=1
nmap <Leader>s <Plug>(easymotion-s2)
nmap <Leader>nt :NERDTreeFind<CR>

When I'm using vim-tmux-tavigator without tmux all work properly, but when I used in a tmux session the C-h doesn't work.
I think it's a mistake in the tmux configuration but I can't find it.

Thank you very much!

@christoomey
Copy link
Owner

A few questions to help debug:

  • Can you check the following in the shell tmux list-keys -T root | grep 'C-h'?
  • In Vim, can you check :verbose nmap <C-h>?
  • Also, just to confirm, does C-h work when you're just moving between tmux panes, but not in Vim, or not at all?

@javijjavi
Copy link
Author

Hi Chris,

First of all, thank you for your help.

  • tmux list-keys -T root | grep 'C-h'
    Result:
    bind-key -T root C-h if-shell "ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" "send-keys C-h" "select-pane -L"

  • :verbose nmap <C-h>
    Result:

 <C-H>       * :TmuxNavigateLeft<CR>                                                                                                                                                                                                     
        Last set from ~/.vim/plugged/vim-tmux-navigator/plugin/tmux_navigator.vim line 19   

Exactly if I execute Prefix + h in tmux I can change between panels, but when I'm use that in vim-tmux-navigator inside a tmux session that doesn't it seen like C-h works as backward. The rest of the commands works properly.

If I execute bindkey "^H" I get:
"^H" backward-delete-char

I dont know if this can help.

Thank you very much for your help, I'm triying a lot of different things but I dont know what it can be, because out of a tmux session all works fine.

@christoomey
Copy link
Owner

Unfortunately, nothing in your response stands out as odd, so I'm not sure where to go. Just to confirm, did you read back through any of the other related issues (searching for C-h in the issues)? I know this has been a sticking point, and there may be some tips in there. Specifically, I've seen things around neovim vs vim, the TERM setting, etc. Sorry I can't provide much more here.

@javijjavi
Copy link
Author

Thank you, Christ,

Yes, I have been watching the other issues and trying all things, like the TERM. But nothing works.
I'm going to continue trying, if I find the solution I will put it in this issue.

Thanks for your help Christ and for the amazing project 👍

@xq-chia
Copy link

xq-chia commented May 26, 2021

solution found at tmux/tmux#1838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants