1

Given: Linux Mint 20.2, Emacs 27.2

Q: E.g. "Hello, how are you?" Suppose whole sentence has foreground color = white. And I want to change color (e.g to red) of only word "Hello". A: There is a general way of highlighting a word or regular expression using any face you want.
Try M-x highlight-regexp (bound to M-s h r). It prompts you for the text to highlight and then it gives you the option to pick any face you want to use. To get a list of all faces, use M-x list-faces-display. Once you have highlighted all occurrences of a word, you can remove the highlights with M-x unhighlight-regexp (bound to M-s h u).

 Here result:

enter image description here

Q: Yes, but M-x highlight-regexp is highlighting word "Hello" in the whole text. E.g. if word "Hello" occur 3 times in the whole buffer it will be highlighting. But I need to highlighting only one word "Hello" exact on the sentence "Hello, how are you?" after Here result:. Is it possible on org mode?

P.S. The ideal scenario is to select some region and highlighting only it

4
  • 3
    This suggesting the highlight library might be useful
    – GNUmon
    Commented Sep 9, 2021 at 15:02
  • See Text properties.
    – NickD
    Commented Sep 9, 2021 at 15:30
  • 1
    Does this answer your question? Highlight region
    – Drew
    Commented Sep 9, 2021 at 15:57
  • Would narrowing (even if not ideal) work for your goals maybe ? And as a fun workaround (sorry for the noise..) we might use query-replace: a). Mark region, b). M-% to call query-replace, c) Choose/write "Query replacing Hello with Hello" <RET>, d) See Hello highlighted in the region (with the replacement artifacts of course :)
    – Y. E.
    Commented Sep 9, 2021 at 17:02

0

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.