Add word under cursor to search pattern

后端 未结 2 1441
一整个雨季
一整个雨季 2021-02-12 18:03

Using * when the cursor is on a word theWord, vim directly jumps to the next appearance of exactly that word, i.e. performes /\\

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-12 18:33

    Try something like:

    1. * (to search for a word)
    2. move somewhere else
    3. :let @/=@/.'\|\<'.expand("").'\>' this appends to the previous search pattern the current word under the cursor) with some delimiters (\| and the word boundaries...)
    4. if you want to, set up a hotkey for it, like: nnoremap :let @/.='\\|\<'.expand("").'\>'

提交回复
热议问题