Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
And of course, immediately after asking this question, I start hitting the related questions and ultimately come up with the answer via (where else), the man page for less... Guess this question just became rep fodder. –  VxJasonxV Mar 18 '11 at 21:43
    
So either delete your question or post the answer. –  Gilles Mar 18 '11 at 21:56
    
What if I wanted to give the rep to someone instead of throwing it away? :) –  VxJasonxV Mar 18 '11 at 21:58
1  
Don't let reputation influence you on whether to post something. Only think whether you're improving the content of the site. –  Gilles Mar 18 '11 at 22:04
    
I consider cjm's content an improvement, and he got rep to show it. I'm not saying this to rub it in, I'm pointing it out because it's dually beneficial to a user. I didn't post the question for the rep either, I just found the answer on my own after the fact. –  VxJasonxV Mar 18 '11 at 22:26

2 Answers 2

up vote 1 down vote accepted

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.)

share|improve this answer

From man less:

ESC-u

Undo search highlighting. Turn off highlighting of strings matching the current search pattern. If highlighting is already off because of a previous ESC-u command, turn highlighting back on. Any search command will also turn highlighting back on. (Highlighting can also be disabled by toggling the -G option; in that case search commands do not turn highlighting back on.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.