How can I highlight all occurrence of a selected word in gvim? (like notepad++..)
The *
key will highlight all occurrences of the word that is under the cursor.
In Normal mode:
:set hlsearch
Then search for a pattern with the command /
in Normal mode, or <Ctrl>o
followed by /
in Insert mode. *
in Normal mode will search for the next occurrence of the word under the cursor. The hlsearch
option will highlight all of them if set. #
will search for the previous occurrence of the word.
To remove the highlight of the previous search:
:nohlsearch
You might wish to map :nohlsearch<CR>
to some convenient key.
Enable search highlighting:
:set hlsearch
Then search for the word:
/word<Enter>
First (or in your .vimrc):
:set hlsearch
Then position your cursor over the word you want highlighted, and hit *
.
hlsearch
means highlight all occurrences of the current search, and *
means search for the word under the cursor.
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<Enter>
to remove highlights on ocuurences use, I have bound this to a shortcut in my .vimrc
:nohl