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?

  • 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 2: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. 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 at 4: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 at 9:50

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

  • I wasn't aware of this package, thanks for pointing it out! It is perfect for prog modes. Sep 28 at 13:28

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.