Junk Food for the Brain

Open Source and Awesomesauce :)

Stop Vim From Highlighting Search Results

| Comments

You can search to words in vim using the ‘/’ key when you’re in command mode. Unfortunately, new admins in their desperation to find a word may inadvertently specify a term too generic.

Vim provides search highlighting, but sometimes, the results are just plain fugly. For example, when searching for the word module in a httpd.conf file, this is what could happen: [caption id=”attachment_212” align=”aligncenter” width=”300” caption=”Vim showing Highlights”]Vim
showing Highlights[/caption]

Yeah, not really the the most visually pleasing. To temporarily turn of highlighting, just type

:nohlsearch

in vim command mode.

The next time you search for something, or press the ‘n’ key, it will be automatically turned back on.