Troskyvs
Troskyvs

Reputation: 8057

How to cancel vim highlight after I "gd" on a word?

I use "gd" on a word to highlight all its instance, fine. Then I wish these highlight should disappear because I don't want to be disturbed. Any vim command to dis-highlight last result?

Upvotes: 0

Views: 1460

Answers (3)

Hsain Alopaydi9357
Hsain Alopaydi9357

Reputation: 1

You can use control + L or :call clearmatches()

Upvotes: 0

sudo bangbang
sudo bangbang

Reputation: 28219

You can use the function clearmatches or command noh to clear all highlights.

:noh

:call clearmatches()

I've got it re-maped in my .vimrc

noremap <leader>g :noh<cr>:call clearmatches()<cr>

From :h noh

Stop the highlighting for the 'hlsearch' option. It
is automatically turned back on when using a search
command, or setting the 'hlsearch' option.

Upvotes: 2

Ruslan Osmanov
Ruslan Osmanov

Reputation: 21502

Use nohlsearch command, or its short version nohls.

Upvotes: 1

Related Questions