3

I'm trying to remap Control + [hjkl] to navigate among splits, by setting this in my rc file:

" splits navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

However, <C-h> isn't working; it moves the cursor left a character, as if I had hit backspace (i.e. it traverses lines, unlike my h). The other movements work.

Asking (neo)vim for mapping information about <C-h> doesn't show anything suspicious looking:

:verbose map <C-h>
n  <C-H>         <C-W>h
        Last set from ~/workspace/dotfiles/.nvimrc

However, if I ask about <C-j> (which works as expected), it says that <NL> is involved?

:verbose map <C-j>
n  <NL>          <C-W>j
        Last set from ~/workspace/dotfiles/.nvimrc

Changing the order of my nnoremaps doesn't seem to change the behavior.

How should I debug this?

  • 2
    I don't know the details, so for now I'll just comment: I'm pretty sure this has to do with a special key code created with <C-h>. If you try it in a terminal, you will see a similar behaviour. Also see :h backspace. – Karl Yngve Lervåg Mar 10 '15 at 21:47
  • Thanks for the pointer @KarlYngveLervåg. May be worth noting that I use the Dvorak keyboard layout, which places the "h" letter underneath the J key (the "j" letter is underneath the C key). I mention this because :h backspace notes that "<NL>" is related to "CTRL-J". – alxndr Mar 10 '15 at 22:16
  • 1
    Worth trying as a workaround: noremap <C-h> <c-w><c-h> (i.e. <c-h> instead of h) as they are equivalent – jalanb Mar 12 '15 at 12:00
  • @jalanb replacing my <C-h> remap with your suggestion causes an audible bell, and no cursor movement. (Pressing <C-w><C-h> does work jump to the split to the left.) – alxndr Mar 12 '15 at 17:47
3

This is due to a bug in Neovim.

A suggested workaround in that bug is to run the following commands to adjust your terminal's terminfo entry to match what Neovim expects:

infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti
tic $TERM.ti
  • This got flagged as low quality. Perhaps you could add in the information in github.com/neovim/neovim/issues/2048#issuecomment-78045837 which seems to have a workaround? – muru Mar 12 '15 at 19:29
  • @mur Or close the question because it's likely not going to be useful long term. vi.SE isn't a bug reporting forum. – jamessan Mar 12 '15 at 19:31
  • From the question, it's not that obvious this is a bug... This question is probably flagged automatically because it's below a certain numbers of characters & has a link. – Martin Tournoij Mar 12 '15 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.