:best of Vim

Showcasing the top Vim plugins, tips and tricks.

What is Vim?

Vim is a text editor for programmers, power users & command-line junkies.

What is :best of Vim?

:best of Vim showcases the best plugins, extensions & tips for making the most of Vim.

It was built for NoVIMber 2011.

Learn more...

Follow

Switch Off The Current Search

If you run vim with search-highlighting enabled (set hlsearch), there'll be times when you've found what you're looking for and want to switch highlighting back off. Chances are you do something like /asdf to force a failed match. Most of us do. But if that's so, why not try this more elegant approach:

Add this to your .vimrc:

nnoremap <silent> <Leader>/ :nohlsearch<CR>

...then you can type <Leader>/ to kill the current search. By default, <Leader> is mapped to backslash, so \/ kills the search.

Breakdown

:nohlsearch switches search-highlighting off until the next time you search. The nnoremap maps that command to <Leader>/.

See :help <Leader> and :help nohlsearch for more.

Comments...