I'm aware of and use whitespace-mode to great effect. I don't show a glyph/character for spaces because I think it's too noisy and unnecessary. I do highlight trailing spaces red which is great.
Aside from that, I was thinking that it may be useful to specify a glyph such as ·
, if it were possible, for inner consecutive spaces. This means that it excludes trailing whitespace as well as indentation, for example:
print("one·····two");
instead of:
print("one two");
But again, this wouldn't apply to leading/indentation whitespace nor trailing whitespace.
Is this possible?
EDIT: I tried setting whitespace-regexp-search
as:
(setq whitespace-space-regexp "[^ ]\\( \\{2,\\}\\)[^ ]")
I have spaces
and space-mark
in my whitespace-style
:
(setq whitespace-style
'(face indentation trailing empty spaces space-after-tab
space-before-tab tab-mark space-mark))
However, it seems like the whitespace-space-regexp
is only for the spaces
face highlighting, and isn't used for setting the space-mark
. Here's the effect:
Notice that all other spaces are still showing the space-mark, even though what I'd like is for consecutive spaces of 2 or more to show it. The inner consecutive spaces are indeed being highlighted differently, but I only did that to show the difference between what's being matched by whitespace-space-regexp
and the space-mark
character.
In fact I just noticed that even the numberline is showing the space-mark.
It looks like the space-mark
is simply matched based on a character, which I guess makes sense, so perhaps this isn't possible after all.
Note: As outlined in my post, I recognize that this isn't possible via whitespace itself, what I'm curious about is whether it's possible to do at all. I found some uses of font-locking such as this one which accomplish replacing pattern matches with a character. I'm wondering if it would be possible to use something like this but have it replace the spaces in the region matched with the middle dot for example.
compose-region
to like replace one string with another, such as this one, but I can't figure out how to make it replace the region with another string or replace all spaces in the region with the middle dot with something likesubst-char-in-region
. Is that even possible?whitespace mode
but one could use overlays to achieve that; right? What's the second solution/workaround?