A bunch of A or B's gets printed on the screen when I accidentally scroll with the touchpad in insert mode.

What can I do to prevent such an annoying behavior ?


It's because there is set noesckeys in your .vimrc.

Removing this line in your .vimrc should solve the problem.

If the reason behind this parameter was because some commands such as O are too slow and someone recommended it as a tip, you can instead set ttimeout and set ttimeoutlen=50 instead.

(Tip: If you also want scrolling to be disabled in insert mode, you can inoremap <Up> <Nop> and inoremap <Down> <Nop>. Note that when noesckeys is set, mapping <Up> or <Down> won't work)

If you really need this parameter, you can map the escape sequences sent by the up and down arrow to <Nop>. An escape sequence is a sequence of values that are used to control the terminal (move cursor, clear terminal, etc.). In order to see what escape sequences correspond to the arrows, put yourself in insert mode, press ctrl + v and then the up or down arrow. You should see something like ^]OA or ^]OB. ^ is Vim representation of the value sent by Esc, together with ] they get the terminal attention, and then O and A instruct to move the cursor up. So you can map the following :

inoremap <esc>0A <Nop>                                                         
inoremap <esc>OB <Nop>

Thanks to all the great people on freenode's #vim that helped me.

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.