Highlight all occurrence of a selected word?

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

    Why not just: z/

    That will highlight the current word under cursor and any other occurrences. And you don't have to give a separate command for each item you're searching for. Perhaps that's not available in the unholy gvim? It's in vim by default.

    * is only good if you want the cursor to move to the next occurrence. When comparing two things visually you often don't want the cursor to move, and it's annoying to hit the * key every time.

    0 讨论(0)
  • 2020-12-12 10:33

    Search based solutions (*, /...) move cursor, which may be unfortunate.

    An alternative is to use enhanced mark.vim plugin, then complete your .vimrc to let double-click trigger highlighting (I don't know how a keyboard selection may trigger a command) :

    "Use Mark plugin to highlight selected word  
    map <2-leftmouse> \m   
    

    It allows multiple highlightings, persistence, etc.

    To remove highlighting, either :

    • Double click again
    • :Mark (switch off until next selection)
    • :MarkClear
    0 讨论(0)
  • 2020-12-12 10:33
    1. Add those lines in your ~/.vimrc file

    " highlight the searched items set hlsearch " F8 search for word under the cursor recursively , :copen , to close -> :ccl nnoremap <F8> :grep! "\<<cword>\>" . -r<CR>:copen 33<CR>

    1. Reload the settings with :so%
    2. In normal model go over the word.

    3. Press * Press F8 to search recursively bellow your whole project over the word

    0 讨论(0)
提交回复
热议问题