Let Emacs highlight a pair of syntax keywords

I am learning how to use Emacs to write code (C ++). I was wondering if there is a package (I'm using Emacs 24.3) that can highlight syntax elements that are pairs or belong to the same group? For example, I would like to highlight three elements if

, elseif

, else

at the same time, when the cursor is on any of them, so I can clearly see what the three code blocks belong to the same condition. I think this is useful, especially if there are nested sentences if

. Another scenario would be (I'm not sure if this is the same function as the previous one), when the cursor is on a keyword return

, all keywords return

will be highlighted at the same time. This way I can check all the cases that arise in the function.

By the way, this feature may be less useful in C ++ than in some other languages ​​like shell script or VB.NET where there is no curly brace. But it is still a good reading aid.

+3


source to share


1 answer


I don't think there is such a thing already for C ++. For languages ​​that use SMIE for navigation and indentation in major modes (e.g. ruby-mode), you can enable show-paren-mode

that highlight the corresponding open / close keyword. If you are in "if" it won't highlight else / elseif, tho.



And I don't know of any package that flashes all the "returns" in a function, although it should be fairly easy to write based on beginning-of-defun

and end-of-defun

.

+1


source







All Articles