Highlight all occurrence of a selected word?

后端 未结 15 1690
难免孤独
难免孤独 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:17

    Use autocmd CursorMoved * exe printf('match IncSearch /\V\<%s\>/', escape(expand(''), '/\'))

    Make sure you have IncSearch set to something. e.g call s:Attr('IncSearch', 'reverse'). Alternatively you can use another highlight group in its place.

    This will highlight all occurrences of words under your cursor without a delay. I find that a delay slows me down when I'm wizzing through code. The highlight color will match the color of the word, so it stays consistent with your scheme.

提交回复
热议问题