I have a question regarding the search term and how it's saved in Emacs, actually I want to know how to clear it.

You know how you can clear the search results highlighting with (evil-search-clear-highlight) and such?

This only disables the display of the search terms, internally the search term is still "in memory", i.e. you can still try and go to the next/previous occurance and the highlighting would resume normally.

How do you actually "clear" the current search term?

In Vim you would actually do this to clear the current search term: :let @/ ""

@/is the name of the "register" which holds the most recent search term.

By clearing the search register, the effect isn't only visual (no highlighting), but also it means that searching for next/prev occurance (n/N) would not work after clearing, because there is nothing to search for (empty string).

I'm looking for an Emacs equivalent to this and I don't know the terminology (is it a special killring or special kind of buffer? IDK).

Note also that you cannot simply enter an "empty" search term to overwrite the previous one via normal UI interactions a la /[ nothing / enter ] (using evil-mode), or C-s / M-s o and then just press enter instead of a string (using holy-mode).

I'm using Spacemacs with evil/vim-like-bindings, but I guess the question can be answered independently from the Emacs distribution.

Thanks for your help & suggestions in advance.

  • I don't use Evil or Vim, so I don't quite understand the question. I'm guessing it's probably clear to someone who is familiar with those, but your mention of "search term or killring" makes me wonder. Hopefully someone familiar with them will review it and maybe clarify things, if needed.
    – Drew
    Jan 9, 2021 at 5:39
  • I don't know of a nice solution, but I did have an issue that clearing the search term solved. A solution is given here: emacs.stackexchange.com/a/48282 Mar 12, 2021 at 15:51


Your Answer

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

Browse other questions tagged or ask your own question.