# 0x0082.io

Clear the search

A quick way to clear the most recent search and remove the highlighting of the search pattern, is to overwrite the Last search pattern register ("/) using the :let command:

:let @/ = ""

Writing out that command is a bit tedious, though, so add a mapping to do it even quicker. For instance, with the following mapping, C will clear the search:

nnoremap <silent> C :let @/ = ""<CR>

The Last search pattern register contains the most recent search pattern, and is also used to highlight that pattern. The register is writeable, so it can be used to highlight other patterns without performing a search. As illustrated above, this is done with the :let command.