Is there a command in Vim/Vi to move the cursor to the end of a search highlight?

前端 未结 6 2067
粉色の甜心
粉色の甜心 2020-12-22 23:31

Are there any commands in Vim/Vi to move within a selected search segment?

For instance, if I search for a word, are there any commands to motion the cursor to the

6条回答
  •  借酒劲吻你
    2020-12-23 00:09

    If you just want to place your cursor after the last character of Fish then you could use

    /Fish/e+1
    

    which will place your cursor after the h. (Without the +1 the cursor will end up to the left of the last character.)

    If you are particularly interested in placing the cursor after Fish, but only when it appears in "FishTaco" then you can try one of the following options:

    You can use

    /FishTaco/s+4
    

    and your cursor will end up between Fish and Taco. The /s+4 places the cursor 4 places after the start of the search term.

    You could likewise use

    /FishTaco/e-3
    

    which will place your cursor 3 places left of the left side of the last (end) character.

    You can also use

    /FishTaco/b+4 
    

    because /b+4 will be treated as /s+4.

提交回复
热议问题