I use C-s to search a pattern in a buffer. Then when I move the cursor, the highlighted matches lose highlight. Can I keep highlights however I move my cursor, or even edit the buffer?
What about when I search using regex?
Thanks.
There's some built-in highlighting functionality bound to key sequences starting with M-s h
. To see them all, type M-s h C-h
to read about the Global Bindings Starting With M-s h
.
The specific functionality you want is bound to M-s h r
, highlight-regexp
.
You can do this by using lazy highlight in your .emacs
(setq lazy-highlight-cleanup nil)
M-x customize-option
. Also, lazy-highlight-cleanup
is a command, which you can use to remove the highlighting on demand at any time.
– Drew
Jun 13 '16 at 22:38
lazy-highlight-cleanup
: Controls whether to remove extra highlighting after a search. If this isnil
, extra highlighting can be "manually" removed withlazy-highlight-cleanup
. – lawlist Mar 24 '15 at 18:29hl-anything
package available on MELPA. – Kaushal Modi Mar 25 '15 at 10:30