Mapping in vimrc causes bizarre arrow behaviour

后端 未结 5 1151
孤街浪徒
孤街浪徒 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:30

    Problem is that when you press an arrow terminal emits something like OA. Vim part that supports terminal seems to use the same mapping mechanism to do the job as you are using: while nmap OA will tell you nothing, call feedkeys("\eOA") will move one line up and call feedkeys("\eOA", 'n') will add letter A beyond current line. With your mapping being noremappable you forbid vim to use as a part of the key. The problem is that you need remappable mapping here, but can have remappable mapping without it being recursive as well only if it starts with {lhs}, but :nohOA is not going to work. I thought the following code will (it uses and function with side effect to make be the first character of the actual {rhs} and still launch :noh), but in fact it does not:

    function s:NoHlSearch()
        nohlsearch
        return "\e"
    endfunction
    nmap   NoHlSearch()
    

    . I have no other idea how to solve the problem of having non-recursive remappable mapping which includes {lhs} but not at the start.

提交回复
热议问题