6

I've found that using the highlight-symbol-mode provided by highlight-symbol works very nicely for highlighting all occurrences of the symbol at point, automatically (without my pressing anything). However, I would like to highlight all other occurrences of the symbol at point: that is, the actual symbol point is on should not be highlighted.

I can't find anything in customize-group highlight-symbol or in highlight-symbol.el for this. Through Google, I haven't found any reference to other packages that support the functionality I want.

How can I get automatic highlighting of all other occurrences of the symbol at point?

Resigned June 2023
  • 1,552
  • 15
  • 20
  • FWIW, I'm curious as to why you want to do that. Is it because highlighting the occurrence at point is distracting, or is there some special use case? – Drew Jul 27 '16 at 02:52
  • 1
    @Drew: I like to turn the idle delays on these sorts of things down to zero, which means they have to be unobtrusive. It is, indeed, quite distracting to have the highlight constantly shift with each new word you type. – Resigned June 2023 Jul 27 '16 at 12:30
  • Agree this is annoying while typing, for evil-users, it can be disabled in insert mode: (with-eval-after-load 'evil (add-hook 'evil-insert-state-entry-hook (lambda () (highlight-symbol-mode 0)) nil t) (add-hook 'evil-insert-state-exit-hook (lambda () (highlight-symbol-mode 1)) nil t)) - I find this avoids the annoyance of the current word at the cursor being highlighted. – ideasman42 Sep 16 '21 at 04:37
  • I think there's hardly the need for an external package. Take a look at isearch-forward-symbol, isearch-forward-symbol-at-point, hightlight-symbol-at-point, etc. These are all bound to the M-s prefix. – aadcg Sep 27 '21 at 09:50

1 Answers1

1

See: idle-highlight-mode which has an option idle-highlight-exclude-point to exclude highlighting the symbol at the point.

ideasman42
  • 8,786
  • 1
  • 32
  • 114