Highlight all occurrence of a selected word?

后端 未结 15 1635
难免孤独
难免孤独 2020-12-12 10:05

How can I highlight all occurrence of a selected word in GVim, like in Notepad++?

15条回答
  •  醉梦人生
    2020-12-12 10:12

    First ensure that hlsearch is enabled by issuing the following command

    :set hlsearch
    

    You can also add this to your .vimrc file as set

    set hlsearch
    

    now when you use the quick search mechanism in command mode or a regular search command, all results will be highlighted. To move forward between results, press 'n' to move backwards press 'N'

    In normal mode, to perform a quick search for the word under the cursor and to jump to the next occurrence in one command press '*', you can also search for the word under the cursor and move to the previous occurrence by pressing '#'

    In normal mode, quick search can also be invoked with the

    /searchterm
    

    to remove highlights on ocuurences use, I have bound this to a shortcut in my .vimrc

    :nohl
    

提交回复
热议问题