Vim: search and highlight but do not jump

后端 未结 12 2103
一生所求
一生所求 2020-12-02 18:02

The super star (*) key in Vim will search for the word under the cursor and jump forward to the next match. The user can jump to the next matches with the n key.

12条回答
  •  無奈伤痛
    2020-12-02 18:49

    I haven't seen this one yet:

    nmap * "syiw: let @/ = @s

    It's very short and does not involve jumping around which can result in blinking.

    Explanation: copy the word under cursor to s register and then set the search register (/) to the content of s register. The search register is not writeable directly, that's why the let is necessary and hence the silent to keep vim's command line clean.

提交回复
热议问题