Last Updated: February 25, 2016
·
811
· spf13

Clearing highlighted search

Vim searching is great. It highlights all the places your search term matches and keeps it highlighted while you continue to edit.

But what do you do when you want to stop highlighting that search?

Most people do something like this...

/afewoijqohag

There is a better way though, add the following line to your .vimrc and easily unhighlight those terms.

"clearing highlighted search
nmap <silent> <leader>/ :nohlsearch<CR>

Then type <leader>/ to clear that search.

I've mapped leader to ',' which is in a more convenient location on US keyboards.

"The default leader is '\', but many people prefer ',' as it's in a standard
"location
let mapleader = ','

... or simply install spf13-vim, a popular vim configuration & distribution that stays true to the feel of vim while providing modern features like a plugin management system, autocomplete, tags and tons more.