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.

  • 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
  • 2
    So either delete your question or post the answer. – Gilles 'SO- stop being evil' 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
  • 3
    Don't let reputation influence you on whether to post something. Only think whether you're improving the content of the site. – Gilles 'SO- stop being evil' 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

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

  • 15
    Esc + u is a very important way to do this on OSX where Alt + u gives you a totally unrelated character. – 9000 Feb 23 '16 at 21:35
  • 2
    I assume on OSX it's pressing Esc, releasing it, then pressing u, right? – Volker Siegel Feb 23 '16 at 23:15
  • Yes; I would like to remove the "+", but it's too late to edit the comment. – 9000 Feb 24 '16 at 16:01
  • As a workaround, you can just copy it to a new comment, edit that, and delete the old one. – Volker Siegel Feb 24 '16 at 20:59
  • 2
    That difference has nothing to do with OS X, but with your terminal emulator. iTerm for example has the ability to assign Alt something that is in accordance with the behavior described in this post. – rien333 Jun 14 '19 at 14:43

From man less:


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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