I have some complicated code with variables that use CamelCase. Would it be possible to display such variables with a hyphen (-) or underscore (_), but without modifying the actual text in the buffer. Change would be just for display.
Asked
Active
Viewed 61 times
1 Answers
2
That's exactly what Glasses mode (M-x glasses-mode) does. See MixedCase words and the glasses package documentation (C-h p glasses RET).
Use M-x customize-group RET glasses RET to see the available customizations. Glasses mode uses _ as the sub-word separator by default, but you can use - or another character instead, or use no character but display the mid-word capital letter in a different color. Glasses mode can also convert from snake_case to camelCase on input, if what you're editing never uses snake case.
Gilles 'SO- stop being evil'
- 22,318
- 4
- 56
- 92
-
It works well for me. I would like to change the separator mark from my init file using elisp code. How should the change be? – Dilna Oct 03 '22 at 19:52
-
A problem I have with it is this. It is difficult to distinguish which words get changed. For instance, if one has a mixture of
CamelCase,Under_scoresone would not know which is modified and which is original. Particularly problematic when one is modifying the code. – Dilna Oct 03 '22 at 20:21 -
@konmi Use the customize interface to change the settings. Change the “Glasses Face” to make the capital letter in a different color of font. – Gilles 'SO- stop being evil' Oct 03 '22 at 21:14
-
-
display. See Replacing Specs. – Drew Oct 03 '22 at 03:31