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

Drew
  • 75,699
  • 9
  • 109
  • 225
a_subscriber
  • 3,854
  • 1
  • 17
  • 47
  • 3
    [This](https://emacs.stackexchange.com/questions/30533/highlight-region) suggesting the highlight library might be useful – GNUmon Sep 09 '21 at 15:02
  • See [Text properties](https://www.gnu.org/software/emacs/manual/html_node/elisp/Text-Properties.html). – NickD Sep 09 '21 at 15:30
  • 1
    Does this answer your question? [Highlight region](https://emacs.stackexchange.com/questions/30533/highlight-region) – Drew Sep 09 '21 at 15:57
  • Would [narrowing](https://www.gnu.org/software/emacs/manual/html_node/emacs/Narrowing.html) (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" , d) See Hello highlighted in the region (with the replacement artifacts of course :) – Y. E. Sep 09 '21 at 17:02

0 Answers0