Mapping in vimrc causes bizarre arrow behaviour

后端 未结 5 1154
孤街浪徒
孤街浪徒 2020-11-30 09:53

I am a happy VIM user, although I admit I\'m quite far from being fluent. I found this nice post: Vim clear last search highlighting and I thought I\'d become a better perso

5条回答
  •  遥遥无期
    2020-11-30 10:49

    The mapping

    nnoremap  :noh
    

    will conflict with so called "grey keys" and I believe that it should be used either in GVim only or in terminal Vim by someone who does not use special keys like arrows.

    From what I know (and guess) how Vim processes keys, I would say that it's impossible to do anything with this. For Vim to recognize special key all its components should go in a row, so when you press Arrow Left Vim gets the following sequence of codes:

    [ D

    But after your mapping Arrow Left becomes:

    : n o h l

    [ D

    Vim sees two separate sequences and treats as a single press of Escape key, thus next two codes of Left Arrow key lose their special meaning.

    So I suggest you to map :noh to some other key sequence (e.g. to one starting with , see :help mapleader; I don't recommend you to use F-keys, using them is as bad as using of arrow keys).

提交回复
热议问题