9

I have a text file opened in Spacemacs with evil mode on. When I search for a term by means of /term [Enter] then found "term"s are highlighed.

How do I remove that highlighting? I tried / [Enter] - that didn't work. The highlighting will stick around even after switching to insert mode.

1

3 Answers 3

14

You can achieve the same as entering :noh with the command evil-ex-nohighlight.

But since you are using spacemacs, it can be even simpler: hit SPC s c to clear highlights.

2
  • 1
    SPC s c is what I was looking for - thanks
    – Raffael
    Aug 21, 2018 at 16:35
  • 3
    An alternative is / ESC.
    – mcp
    Jan 4, 2022 at 22:13
4

Do it just like you would do in Vim (I've checked, / RET doesn't work with :set hlsearch), use :noh.

6
  • can I make this permanent by adding it to .spacemacs?
    – Raffael
    Aug 19, 2018 at 16:58
  • I don't understand. :noh is a command you execute to undo highlights. The next time you search, you get the results highlighted. Are you looking for something to prevent search highlights?
    – wasamasa
    Aug 19, 2018 at 18:58
  • let's say I hoped for something more ergonomic than having to enter :noh after using highlighting. but :noh will do the trick.
    – Raffael
    Aug 19, 2018 at 19:21
  • That's fine, I'm asking about your intention. You do understand that a search will highlight the results unless configured otherwise, don't you?
    – wasamasa
    Aug 19, 2018 at 19:38
  • Is there a way of having the highlights go away after a few seconds of performing a search? Apr 2, 2020 at 17:23
0

With the idea that @EFLS mentioned, I added these lines to my .spacemacs file:

(defun dotspacemacs/init ()
  (setq-default
;; ... your other settings
;; ----------------------------------
 ;; don't hightlight search / results
   evil-ex-substitute-highlight-all nil
   evil-ex-search-persistent-highlight nil
;; ----------------------------------
;; ... your other settings
))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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