1

I've got these mappings in my .vimrc:

nnoremap <C-Tab> :tabn<cr>  " cycle tabs
nnoremap <C-S-Tab> :tabp<cr>    " cycle tabs backward

nnoremap <C-J> <C-W><C-J>   " no Ctrl-W needed to navigate up
nnoremap <C-K> <C-W><C-K>   " no Ctrl-W needed to navigate down
nnoremap <C-L> <C-W><C-L>   " no Ctrl-W needed to navigate right
nnoremap <C-H> <C-W><C-H>   " no Ctrl-W needed to navigate left

When I use them (e.g. I press CtrlL or CtrlH), they work, but I get a “bong” alert sound.

I get the sound in Windows (GVim 8.1 on Win 10), and in my terminal (Vim 8.1 on CentOS via SecureCRT).
There's no sound when I enter the commands manually (e.g. CtrlW,CtrlL), with or without the nnoremap in place.
There's no sound when I use those key combos in other programs.

Why is that happening, and how can I stop it?

  • Side note, a few of those mappings may be more than one thing (Ctrl-H is sometimes backspace, Ctrl-L a screen redraw, and Ctrl-J a newline like hitting Enter) – D. Ben Knoble May 29 '19 at 21:47
  • Good to know. In normal mode, C-H and C-J are redundant (for my purposes). Screen redraw is sometimes handy, though. – Jacktose May 30 '19 at 16:57
  • When I come to think about it, it is possible that there is no window below your window and that is why it beeps. – eyal karni Jun 2 '19 at 23:43
2

It is a bad habit to do spaces and remarks in the same line of the mapping. I believe it includes them in the mapping and it causes the beep(about the remark I am not sure). So try to remove them and see what happens.

I have asked a similar question Beep upon using a mapping .

As a temporary solution:

set visualbell t_vb=

Disables all beeps

| improve this answer | |
  • 1
    You're so right! I forgot to include the pipe. Changed to e.g. nnoremap <C-J> <C-W><C-J>| " no Ctrl-W needed to navigate up and there are no bells. (Also no bell if I remove everything after the last >.) – Jacktose Jun 3 '19 at 16:19

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.