christoomey / vim-tmux-navigator

Seamless navigation between tmux panes and vim splits

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with ctrl-h in neovim

pwntester opened this issue · comments

Hi, First of all, this is a great addition to my workfow, thanks!

I know, this is probably a problem with neovim, but control-h does not work there using standard configuration. Is there anything that can be done with any mapping settings?

Thanks
A

Hi @pwntester, glad you've found it useful!

I'm not a neovim user myself, but my guess is that the issue lies there. You can confirm that the mapping is configured properly by running:

verbose nmap <C-h>

And it should mention tmux navigator.

Also, I think #61 is about the same issue and might contain a fix.

Thanks!

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
tic $TERM.ti

That worked for me, thanks!!!

Glad to hear it. Closing this now as your issue seems resolved, but please feel free to reopen or comment if needed.

I'm seeing this issue too, everything works except for <C-H> despite the fact that :TmuxNavigatorLeft is fine. Pasting the snippet above does fix the problem, but not knowing what it does, I feel a little weird using it.

Edit: Not sure why, but even the above fix isn't working for me anymore

I think might be a problem with the bash shell and the regex.

I had

set shell=/bin/bash

That shell was 3.2

I changed it to

set shell=/usr/local/bin/bash

This one is 4.3

and the issue seems to be gone.

Pasting the fix @pwntester mentioned and using a brew based 4.3 version of bash seems to have fixed this issue for me for neovim when not run inside of tmux. But I still can't C-h in vim when using tmux. It'll navigate the tmux splits with C-h just fine, but when it gets to vim, then C-h is just a noop.

Update: I checked echo $TERM and it was set to screen-256color even though I had it set in iterm2 as xterm-256color. I added export TERM='xterm-256color' to my ~/.zshrc and then C-h worked.

Was having the same issue with everything but Ctrl+h working in Neovim and Tmux.

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\177/' > $TERM.ti
tic $TERM.ti

No idea what that snippet does, but after running it in zsh, Ctrl+h now works

Hm I can't run tic $TERM.ti to verify the fix. Otherwise I'm also having this problem. Using homebrew zsh.

also having the issue @felixjung / @christoomey.
osx 10.10.5
homebrew
tmux
zsh
neovim (terminal brew vim works fine)
i've tried with both xterm-256color and screen-256color

output of verbose nmap <C-h>:

<C-H>       * :TmuxNavigateLeft<CR>
Last set from ~/.nvimrc

UPDATE: nevermind, I just followed the barrage of solutions over at neovim/neovim#2048;

seems to all work again.

I'm experiencing what I think may be a strange variation on this problem... for me, <C-h> is being captured by Neovim (in both normal and insert mode) and sending <BS>, despite the fact that it is mapped to :TmuxNavigateLeft.

:verbose nmap <C-h> produces the following:

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

<C-h> seems to work in Neovim, it's just sending <BS>, which I have mapped to gg, so it's putting my cursor at the top of the file I'm in. Which makes me suspect that something somewhere has mapped <C-h> to <BS> with nmap instead of nnoremap.

Using Vim instead of Neovim, there is no problem. Adding nnoremap <C-h> :TmuxNavigateLeft<CR> to my ~/.nvimrc doesn't help.

@megalithic Do you recall what exactly from that Neovim issue solved it for you?

Thanks!

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
tic $TERM.ti

That worked for me, thanks!!!

+1 on this -- it worked for me. It sounds like they are working on a fix for this in Neovim, something about upgrading the version of libtermkey that they use.

@daveyarwood SUPER late responding to you; sorry about that. yep, your tic block did the trick for me.

be sure to run:

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
tic $TERM.ti

within your HOME directory

@geoffharcourt I think I remember you sharing some comments around this recently. Can you shed any light on this for me (I'm not using neovim so not familiar with the issue).

Is there a clean solution we can recommend?

I have <BS> in normal mode mapped to :TmuxNavigateLeft<cr> like this in my dotfiles. This solution fixes Vim/Tmux navigation, but should just be a bandaid until the Neovim team resolves their terminal keybinding issues. The issue has been open for months and doesn't seem to close to a consensus resolution yet.

There are some other solutions available, but they involve updating with tic, and I don't think we should be asking end-users to make those changes lightly.

I just had an issue with this too. Here's what solved it for me:

  • You have to fix Neovim somehow so that it doesn't override <C-h>. Updating tic as in this comment worked for me, but treating <C-h> as <BS> and mapping TmuxNavigateLeft to it would work too (hammer vs. scalpel).
  • Make sure you're using the tmux mappings described in the README. Originally I didn't do this because I was having some sort of issues with it, but everything seems to work great now.

If anyone has this problem with iTerm2 I found a solution here.
Specifically badeip says to go to
iTerm -> Preferences -> Keys
Add a new Global Shortcut Key. (Press +)
Press Ctrl+h as Keyboard Shortcut
Choose Send Escape Sequence as Action
Type [104;5u for Esc+

@dckesler your solution worked for me 👍 !!

Actually - no dice when I don't have 2 vim splits open between Tmux panes.

If I have 2 split tmux panes, and vim is open on the left, and not open on the right - can't switch.

I noticed that when trying control-h in prezto, it was enabling my vim bindings.

Removed that plugin and now 4;5u is output whenever using control-h in a tmux split.

So, something in combination with removing this line in my .zshrc file, and this suggestion fixed things.

Hate that I don't know the exact ticket to get it working... will have to see if I can reproduce later.

@thewatts it appears you have an involved enough setup with Prezto, etc. that you'd be best off bisecting your configuration to find the offending portions.

  1. Start with the most vanilla configuration possible (comment out everything in your tmux.conf other than this plugin's required lines, disable any zsh tools like Prezto / oh-my-zsh / tmux plugin manager, etc.)
  2. Demonstrate that the vim-tmux-navigator works in your terminal
  3. Uncomment half of what's commented, test that it works
  4. Roll back if the uncommenting breaks the plugin and then try uncommenting fewer lines.

One of the pitfalls of having a very involved setup (I say this as someone who runs a very large number of Vim plugins) is that debugging these problems takes a little time due to interaction across all the different things you've got in the mix.

The solution above about monkey-patching the terminfo, has to be run every time?

@christoomey this is actually a Neovim issue with a long history and not anything specific to the plugin. I think we should close this issue out, folks can get involved in the discussion on the Neovim repo.

@geoffharcourt I totally agree. Do you think you could write up a brief summary for the troubleshooting section of the README w/ link to this issue and or the neovim issue? Assuming it's not too much to ask, I've just added you as a collaborator so feel free to open as PR, or if you'd prefer, you can add the summary here and I'll add then we can close this issue.

This fixes it perfectly for me:

if has('nvim')
    nmap <BS> :<C-u>TmuxNavigateLeft<CR>
else
    nmap <C-h> <C-w>h
endif

(fixed, see below) Even without neovim/vim, I cannot jump to the left pane with ctrl-h with the provided modifications to .tmux.conf. This isn't solely a neovim issue and/or there are multiple issues. I'm using tmux 2.2.

Edit: I'm using mobaXterm to ssh to my workstation. In the terminal settings I unchecked "Backspace sends ^H" and this resolved my issue. I'm using neovim btw and no new settings required for this to work.

@christoomey so sorry this took so long to get to, I haven't had much investment time lately. I've suggested #122 to update the documentation and link to solutions.

I have the issue too when i switch termite to xterm.

so i adjust configure in .zshrc

in origin env

tmux
zsh
termite
vim

export TERM='screen' is fine!

my new env

tmux
zsh
xterm
vim 

export TERM='screen-256color' is worked for me

Has issue been fixed in 0.2.0?

commented

@bernastoc did you ever get this working ? I'm in the same situtation - not a neovim issue, but just tmux - and also using MobaXTerm

@bernastoc did you ever get this working ? I'm in the same situtation - not a neovim issue, but just tmux - and also using MobaXTerm

The second paragraph in my post describes what I did ;)

commented

Ah, somehow missed that. Thanks!