Reputation: 2550
I would like to show ‘␣’ instead of non-breaking spaces since they are invisible by default, and added the following lines to my vimrc
:
syntax match nonbreaking "\%xa0" conceal cchar=␣
set conceallevel=1
highlight nonbreaking ctermbg=NONE guibg=NONE
While this works, it also adds a background colour to all occurrences of non-breaking spaces – even with the {cterm,gui}bg=NONE
line:
Is there a way to “hide” U+00ad behind ‘␣’ without affecting how it's highlighted at all?
Upvotes: 3
Views: 2278
Reputation: 172540
I'd also recommend against using the conceal feature for this, as it can interfere with the existing syntax highlighting; the use of 'listchars'
as suggested by @zmo is preferable (but :set list
has side effects, e.g. with wrapping, too).
For completeness, you can influence the visual appearance of the concealed characters via the Conceal
highlight group.
:hi clear Conceal
clears the existing highlighting.
Upvotes: 2
Reputation: 24812
well, it's not a direct answer to your question about background of concealed characters, though here is a solution to your problem:
to show non-breakable spaces as ␣
you should better use the listchars
setting:
:set listchars=nbsp:␣
and here's my complete listchars
setting, in case you're interested:
:set listchars=eol:¶,trail:~,extends:⫸,precedes:⫷,tab:▸ ,nbsp:␣
and this will not affect the colours.
More about it :he listchars
HTH
Upvotes: 5