I want to change the colour of substrings inside comments in a buffer. So that text enclosed by braces are coloured differently.

For the following bash comment, I want the text enclosed bf {} to be differently coloured. For instance, the comment will be green but with {this and that} being blue.

## This is a comment that describes {this and that}.

1 Answer 1


This is more or less a duplicate of this question (where you probably forgot to accept the correct answer).

Anyway, you can achieve this using hi-lock-mode and evaluating the following expression

(highlight-regexp "^## .*\\({.+}\\)\.*$" 'face-aid 1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.