Unhighlight last search in ‘less’

lesssearch

When you use a / forward search or a ? backward search in less, all instances of the file get highlighted. After I've found the instance of the word I'm looking for, what is the most correct way to unhighlight something?

Currently I just press / then mash gibberish into the input field. No results = no highlights!

I'm looking for something akin to vim's :nohl feature, in less.

Best Answer

You can use Alt+u to remove the highlight on last search results.
You can highlight them again with Alt+u, it's a toggle.

Switching off the highlight does not switch off the status column, showing marks on each line containing a match, if the column is enabled using options -J or --status-column or keys -J.

To hide the status column, use -+J.

To show the status column, use -J.

(Technically, Alt+u it's equivalent to ESCu on terminal level - that is why the Alt-key is not mentioned in the man page.)

Related Question