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

<C-h> (CTRL-H) does not work in the new TUI #2048

Closed
rainerborene opened this issue Feb 23, 2015 · 169 comments · Fixed by #5758
Closed

<C-h> (CTRL-H) does not work in the new TUI #2048

rainerborene opened this issue Feb 23, 2015 · 169 comments · Fixed by #5758
Assignees
Labels
bug issues reporting wrong behavior tui
Milestone

Comments

@rainerborene
Copy link
Contributor

I use the following mappings on my .nvimrc and it does not work using tmux inside urxvt.

nnoremap <C-h> <C-w>h " only C-h does not work.
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

env output

BROWSER=firefox
COLORFGBG=7;0
COLORTERM=rxvt
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-zNeYXuznrs,guid=844332d151bf76af0ebfba3754e5f937
DESKTOP_SESSION=i3
DESKTOP_STARTUP_ID=i3/i3-sensible-terminal/725-0-arch_TIME89282
DISPLAY=:0
DOCKER_HOST=unix:///var/run/docker.sock
EDITOR=vim
GDMSESSION=i3
GDM_LANG=en_US.utf8
GPG_TTY=/dev/pts/5
GREP_COLOR=97;45
GTK_MODULES=canberra-gtk-module
HG=/usr/bin/hg
LANG=en_US.utf8
LC_MEASUREMENT=pt_BR.utf8
LC_MONETARY=pt_BR.utf8
LC_NUMERIC=pt_BR.utf8
LC_PAPER=pt_BR.utf8
LC_TIME=pt_BR.utf8
LS_COLORS=no=00;37:fi=01;34:di=00;34:ln=00;36:pi=40;33:so=00;35:do=00;35:bd=40;33;01:cd=40;33;01:or=00;05;37;41:mi=00;05;37;41:su=37;41:sg=30;43:tw=30;42:ow=04;34:st=37;44:ex=00;32:*.cmd=00;33:*.exe=00;33:*.com=00;33:*.btm=00;33:*.bat=00;33:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz=01;31:*.bz2=01;31:*.bzip2=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.apk=01;31:*.gem=01;31:*.jpg=00;35:*.JPG=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.svg=00;35:*.svgz=00;35:*.mng=00;35:*.pcx=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.cgm=00;35:*.emf=00;35:*.eps=00;35:*.CR2=00;35:*.ico=00;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.html=00;32:*.rst=00;32:*.md=00;32:*.patch=00;32:*.diff=00;32:*.tex=00;32:*.doc=00;32:*.xml=00;32:*.xls=00;32:*.xlsx=00;32:*.doc=00;32:*.docx=00;32:*.ppt=00;32:*.pptx=00;32:*.key=00;32:*.pt=01;32:*.tmpl=01;32:*.in=01;32:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.m4a=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:*.mov=01;36:*.mpg=01;36:*.mpeg=01;36:*.m2v=01;36:*.mkv=01;36:*.ogm=01;36:*.mp4=01;36:*.m4v=01;36:*.mp4v=01;36:*.vob=01;36:*.qt=01;36:*.nuv=01;36:*.wmv=01;36:*.asf=01;36:*.rm=01;36:*.rmvb=01;36:*.flc=01;36:*.avi=01;36:*.fli=01;36:*.flv=01;36:*.gl=01;36:*.m2ts=01;36:*.divx=01;36:*.webm=01;36:*.axv=01;36:*.anx=01;36:*.ogv=01;36:*.ogx=01;36:*.conf=00;36:*.cnf=00;36:*.cfg=00;36:*.ini=00;36:*.properties=00;36:*.yaml=00;36:*.vcl=00;36:*.c=00;33:*.cpp=00;33:*.py=00;33:*.coffesscript=00;33:*.js=00;33:*.rb=00;33:*.sh=00;33:*.zsh=00;33:*.env=00;33:*.bash=00;33:*.php=00;33:*.java=00;33:*.zcml=00;33:*.db=00;32:*.sql=00;32:*.json=00;32:*.plist=00;32:*.fs=00;32:*.tex=01;37:*.rdf=01;37:*.owl=01;37:*.n3=01;37:*.ttl=01;37:*.nt=01;37:*.torrent=01;37:*.xml=01;37:*Makefile=01;37:*Rakefile=01;37:*build.xml=01;37:*rc=01;37:*.nfo=01;37:*README=01;37:*README.txt=01;37:*readme.txt=01;37:*README.markdown=01;37:*README.md=01;37:*.ini=01;37:*.yml=01;37:*.cfg=01;37:*.conf=01;37:*.c=01;37:*.cpp=01;37:*.cc=01;37:*.log=01;30:*.bak=01;30:*.aux=01;30:*.lof=01;30:*.lol=01;30:*.lot=01;30:*.out=01;30:*.toc=01;30:*.bbl=01;30:*.blg=01;30:*~=01;30:*#=01;30:*.part=01;30:*.incomplete=01;30:*.swp=01;30:*.tmp=01;30:*.temp=01;30:*.o=01;30:*.obj=01;30:*.pyc=01;30:*.pyo=01;30:*.class=01;30:*.cache=01;30:*.egg-info=01;30:
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
SHELL=/usr/bin/fish
SHLVL=4
SSH_AGENT_PID=746
SSH_AUTH_SOCK=/tmp/ssh-J6jf9XAbiTjD/agent.725
TERM=screen-256color
TERMINFO=/usr/share/terminfo
TMUX=/tmp/tmux-1000/default,1161,11
TMUX_PANE=%27
WINDOWID=23068681
WINDOWPATH=1
WINEARCH=win32
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=i3
XDG_SESSION_ID=c2
XDG_VTNR=1
__fish_bin_dir=/usr/bin
__fish_datadir=/usr/share/fish
__fish_help_dir=/usr/share/doc/fish
__fish_runtime_dir=/run/user/1000
__fish_sysconfdir=/etc/fish
fish_greeting=
@rainerborene rainerborene changed the title map <C-h> <C-w>h does not work in the new TUI <C-h> does not work in the new TUI Feb 23, 2015
@jwkvam
Copy link

jwkvam commented Feb 23, 2015

I experience the same on OSX with iterm2.

@tarruda
Copy link
Member

tarruda commented Feb 23, 2015

what is displayed if you type <c-v><c-h> in insert mode?

@jwkvam
Copy link

jwkvam commented Feb 23, 2015

With nvim, Commit: 0df6b91
<BS>
With vim 7.4.488
^H
I'm using the same config for both vim and neovim.

@rainerborene
Copy link
Contributor Author

Same here. <BS>

@tarruda
Copy link
Member

tarruda commented Feb 23, 2015

any chance you compiled against the wrong libtermkey version? Does rm -rf .deps build && make && build/bin/nvim change anything?

@jwkvam
Copy link

jwkvam commented Feb 23, 2015

Same behavior for me.
- downloading... src='https://github.com/neovim/libtermkey/archive/8c0cb7108cc63218ea19aa898968eede19e19603.tar.gz'

@tarruda
Copy link
Member

tarruda commented Feb 23, 2015

what is displayed when you press ctrl+h in the cat program?

@jwkvam
Copy link

jwkvam commented Feb 23, 2015

^H, the same happens with xxd.

@foobacca
Copy link

I use <C-h> for gT (move to tab left) and just tested and it works as expected. And <c-v><c-h> shows ^H

I'm using the PPA version of nvim - tried 0.0.0+git201502201750+6ubuntu14.04.1 and 0.0.0+git201502221955+6ubuntu14.04.1 - both work fine.

I run in tmux in terminator on Ubuntu.

@jwkvam
Copy link

jwkvam commented Feb 23, 2015

FWIW, I bisected the merges and it broke at merge #2039

@tarruda tarruda self-assigned this Feb 24, 2015
@tarruda
Copy link
Member

tarruda commented Feb 24, 2015

@jwkvam that PR didn't change anything related to parsing these keys: https://github.com/neovim/neovim/pull/2039/files

As I said, there was a problem with how libtermkey handled ctrl+h or backspace, but it was fixed in a recent commit: neovim/libtermkey@619c0c1

@geoffharcourt
Copy link
Contributor

Experiencing the same problem on the latest build (61c98e7). I'm in iTerm, and the problem happens both inside and outside of tmux. <c-v><c-h> prints <BS>.

@geoffharcourt
Copy link
Contributor

One further detail: this problem happens in nvim with a blank .vimrc.

@acoffman
Copy link
Sponsor

I'm experiencing exactly this same problem.
It happens on a totally clean install with no plugins:

The entire contents of my .nvimrc are

" navigate splits
nmap <silent> <C-k> :wincmd k<CR>
nmap <silent> <C-j> :wincmd j<CR>
nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-l> :wincmd l<CR>

I'm using OSX 10.10.2 with iTerm2 and NVIM 0.0.0-alpha+201502261923. The problem occurs both inside and outside of tmux and also in Terminal.app. All three other bindings work, but <C-h> does not.

@acoffman
Copy link
Sponsor

Oh, and <c-v><c-h> in insert mode prints <BS> in the current buffer.

@adambiggs
Copy link

Same thing here. Default left-navigation key mapping for the vim-tmux-navigator plugin is broken.

iTerm on OSX 10.10.2. With & without Tmux. Also broken in Terminal.app. Works fine in terminal MacVim.

@lambdahands
Copy link

Experiencing this as well.

iTerm on OSX 10.10.2

@af
Copy link

af commented Mar 3, 2015

I'm also fighting with trying to bind <C-h>. iTerm2 on OS X 10.10.2, using NVIM-0.0.0-alpha+201503020458.

It's not a good solution, but if you're looking for a workaround, replacing <C-h> with <bs> in my mappings did the trick for me (assuming you don't use the backspace key).

@geoffharcourt
Copy link
Contributor

I think we have enough reports now no one else needs to confirm there's a problem, so no further need to add on to this thread.

@justinmk justinmk added the bug issues reporting wrong behavior label Mar 3, 2015
@kopischke
Copy link

@tarruda as everybody concerned seems to be using OS X, this (somewhat elderly) post might be relevant: it suggests that OS X terminals are defining a different erase character than Linux in the xterm terminfo, thus causing occasional issues with Backspace / Ctrl-h (which is the backspace equivalent when you use Emacs readline keybindings).

@ladislas
Copy link

ladislas commented Mar 3, 2015

Another alternative is to use <C-w-h> which does the trick for me :)

@ZyX-I
Copy link
Contributor

ZyX-I commented Mar 4, 2015

@ladislas What is w modifier? Win key?

@ladislas
Copy link

ladislas commented Mar 4, 2015

@ZyX-I my bad, it's <C-w>h which means you have to presse the Ctrlkey + w letter key + h letter key.

It's just from the remap actually... nnoremap <C-h> <C-w>h

@LuRsT
Copy link

LuRsT commented Mar 4, 2015

@kopischke, I wasn't going to chime in since there are already a lot of reports for this bug, but I just wanted to add that I'm experiencing the same on Arch linux (Using the AUR package which may be outdated)

Update: I don't have this problem in Ubuntu (using the package from apt-get)

@fishman
Copy link

fishman commented Mar 4, 2015

i'm in archlinux too. this must be because of one the terminal libraries.

in nvim c-h produces <BS> whereas in vim in produces ^H

EDIT: and i've built it manually too, just in case the versions might cause a problem. i also tried it in xterm to see if the issue is rxvt specific

 if has('nvim')
     nmap <BS> <C-W>h
 endif

works for example. though that's a terrible workaround

jcmorrow pushed a commit to jcmorrow/dotfiles that referenced this issue May 3, 2016
Because now <c-h> works again thanks to
neovim/neovim#2048 (comment)
expipiplus1 added a commit to expipiplus1/dotfiles that referenced this issue May 6, 2016
@blueyed
Copy link
Member

blueyed commented May 9, 2016

FWIW, I've found this in tmux source:

/*
 * Check for backspace key using termios VERASE - the terminfo
 * kbs entry is extremely unreliable, so cannot be safely
 * used. termios should have a better idea.
 */
bspace = tty->tio.c_cc[VERASE];
if (bspace != _POSIX_VDISABLE && (key & KEYC_MASK_KEY) == bspace)
    key = (key & KEYC_MASK_MOD) | KEYC_BSPACE;

https://github.com/tmux/tmux/blob/fe4e9470bb504357d073320f5d305b22663ee3fd/tty-keys.c#L625-L632

And it gets set for panes initially: tio2.c_cc[VERASE] = '\177'; (https://github.com/tmux/tmux/blob/fe4e9470bb504357d073320f5d305b22663ee3fd/window.c#L866).

Not sure if it's really helpful, but might give some idea to fix this.

@justinmk
Copy link
Member

justinmk commented May 9, 2016

@blueyed Yes, that's the traditional way to avoid this issue (Vim uses the same approach): fall back to termios. We would like to do that, but it requires forking libtermkey (or more ideally, getting a hook in libtickit when libtermkey is merged into libtickit).

kthibodeaux added a commit to kthibodeaux/.dotfiles that referenced this issue Jun 3, 2016
kthibodeaux pushed a commit to kthibodeaux/.dotfiles that referenced this issue Jun 3, 2016
kthibodeaux added a commit to kthibodeaux/.dotfiles that referenced this issue Jun 4, 2016
When opening a new shell when tmux is not running then run tmux new

If tmux is already running, give a choice to connect to an existing
session or create a new one (or qQ to not).

With these dotfiles it is not recommended to work outside of tmux due to
neovim/neovim#2048.  While there are many
solutions in the issue thread the one that works best for me is to
rebind c-h in tmux to send the proper command to neovim.  YMMV.
kthibodeaux added a commit to kthibodeaux/.dotfiles that referenced this issue Jun 5, 2016
Previous fix for C-H did not allow for navigating left to a different
tmux pane.

By putting the fix here we can be sure that the C-H binding is only
changed when inside of n/vim.

As always, see here for more information:
neovim/neovim#2048 (comment)
razor-x added a commit to rxrc/nvimrc that referenced this issue Jun 16, 2016
adam-wolski pushed a commit to adam-wolski/configfiles that referenced this issue Jun 16, 2016
ifyouseewendy added a commit to ifyouseewendy/dotfiles that referenced this issue Jun 21, 2016
larrylv added a commit to larrylv/dotfiles that referenced this issue Jun 23, 2016
jackfranklin added a commit to jackfranklin/dotfiles that referenced this issue Jun 24, 2016
vilhalmer added a commit to vilhalmer/System that referenced this issue Jul 1, 2016
This adds the ability to include custom terminfo files in this repo,
which will be used when available. I've used it to fix the bug in OS X's
default terminfos which prevents C-h from working correctly in neovim.
As a result, this commit also removes that workaround from init.vim.

The included ti files were generated using the technique in
neovim/neovim#2048 (comment):

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti && tic $TERM.ti
justjake pushed a commit to justjake/Dotfiles that referenced this issue Jul 22, 2016
This issue crops up because almost all programs special-case backspace
to be ctrl-h.
See neovim/neovim#2048 (comment)
smcabrera added a commit to smcabrera/castillo-cabrera that referenced this issue Jul 30, 2016
akshayjshah pushed a commit to akshayjshah/dotfiles that referenced this issue Aug 4, 2016
@dojoteef
Copy link

dojoteef commented Aug 9, 2016

I know I'm late to the party, but if anyone is looking for a solution with a more limited scope the approach I used will gracefully fallback to termios settings if needed for your terminal without requiring a global setting.

https://github.com/dojoteef/dotfiles/blob/master/init/50_nvim.sh#L39
https://github.com/dojoteef/dotfiles/blob/master/source/50_editor.sh#L4

tdy added a commit to tdy/dots that referenced this issue Aug 11, 2016
tdy added a commit to tdy/dots that referenced this issue Aug 11, 2016
@justinmk
Copy link
Member

justinmk commented Aug 22, 2016

For those finding this issue, :CheckHealth now detects this problem and suggests a workaround. The same workaround is mentioned in the FAQ.


Update: @blueyed post to ncurses mailing list: https://lists.gnu.org/archive/html/bug-ncurses/2016-11/msg00022.html


Update: #5758 is an attempt to fix this issue.

@neovim neovim locked and limited conversation to collaborators Aug 22, 2016
@justinmk justinmk removed the status:blocked-external Needs a third-party / external change or fix label Dec 12, 2016
@justinmk justinmk modified the milestones: 0.2, 0.3 Dec 12, 2016
@justinmk
Copy link
Member

This is fixed on master (not released yet). To build from source, you probably need to:

rm -rf .deps build

However master is unstable currently, so most users should wait until the next release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug issues reporting wrong behavior tui
Projects
None yet
Development

Successfully merging a pull request may close this issue.