I recently saw this demo. My question is: how is it possible in vim to show whitespace characters under the cursor as dots (in red for example).
I don't think that's showing space under the cursor; I think it's showing trailing spaces. This is controlled by the listchars
option, which controls the behavior of list
. To turn it on, use:
set list
set listchars=trail:·
The color is determined by the hl-SpecialKey
group; you can change it like this:
hi SpecialKey ctermfg=Red
Highlight whitespace before and after the cursor
highlight FooBar guibg=#80a0ff au CursorMoved * :match FooBar /\s*\%#.\s*/
That works for normal mode with gvim. To make it work in terminal vim change the guibg to ctermbg. If you want it also in insert mode, change au CursorMoved
to
au CursorMoved,CursorMovedI,InsertEnter
Although in that case you'd need to tweak the regex since that one matches erroneously non-whitespace characters to the right of the cursor when entering insert mode.
In the regex \%# matches the current cursor position. I had to use . after it since it wouldn't match whitespace to the right of the cursor without it.