How can I search a word after selecting it in visual mode in Vim?

后端 未结 4 658
遇见更好的自我
遇见更好的自我 2021-01-26 02:22

Suppose I have selected a word in visual mode. Now I want to search that word in the document.

How can I do that?

Thanks in advance.

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-26 02:55

    Press y (you'll exit from visual mode after that) then press / Ctrl+r then " end hit enter.

    You can use it to bind // for this action:

    :vmap // y/"
    

    If you select special chars you better use this

    :vmap  // y/=escape(@", '\\/.*$^~[]')
    

提交回复
热议问题