Emacs - highlighting the current word
One editor feature I find really useful when programming is highlighting the word currently under the cursor, like this:
Emacs comes with this functionality built in, but it is very awkward to use.
To highlight the symbol under point (Emacs terminology for “word under
cursor”), you need to use the function highlight-symbol-at-point
which is bound to C-x w .
.
Worse, to remove the current highlighting, you need to run
unhighlight-regexp
with C-x w r RET
.
This is really cumbersome which is a shame because the feature is so useful.
So instead, I wrote a small function to toggle the highlighting of
the symbol under point and bound it to Super-.
:
I am aware that some libraries let me automatically highlight the symbol under point after a short wait, but I actually prefer to keep it manual to reduce visual clutter.
I recently switched back to Emacs after spending four years in Vim. This has been a really interesting journey which I may want to write more about in the future. If you’re curious, let me know in the comments.