1

I'd want to display non standard spaces in Vim so that I could distinguish No-Break space (U+00A0) from Narrow No-Break space (U+202F) by using for example replacement Unicode characters like ␣ (U+2423) and ⸤ (U+2E24) respectively.

After investigating, the best I could do was displaying the same replacement character for both no-break space types by using :

:set list
:set listchars=tab:▸\ ,eol:¬,trail:\ ,nbsp:␣

So, the listchars nbsp parameter does not differentiate standard and narrow no-break space (and it also needs the trail parameter to function proprerly, by the way).

Is there any workaround for this ?

3
  • You might be interested in the Vi and Vim Stack Exchange.
    – muru
    Feb 17, 2016 at 21:26
  • You can use the conceal feature for that.
    – kba
    Feb 17, 2016 at 21:37
  • Note that many of those characters (UTF-8 not Extended Latin) do not work unless encoding is also set to utf-8. Because of that I like to use... set listchars=tab:»·,nbsp:×,trail:«,extends:±
    – anthony
    Nov 8, 2017 at 4:05

1 Answer 1

1

You can use syntax matching and conceal:

set conceallevel=1
syn match NBSP '\%xa0' conceal cchar=␣
syn match NarrowNBSP '\%u202F' conceal cchar=⸤

The effext:

enter image description here

You could also use set conceallevel=2.

conceal replacements aren't shown in the line on which the cursor is. For, that set concealcursor:

set concealcursor=n
3
  • Hmm, sorry to ask help again, but I have a problem to get these instructions to work automatically. I added them in ~/.vimrc, but for every file I want to edit, I have to source .vimrc to get it to work ! How can I avoid that ? Thanks.
    – hutou
    Feb 18, 2016 at 13:44
  • @hutou I cannot reproduce that. It works fine for me without having to source .vimrc manually. Could it be that the match groups use the same names as something else in your syntax files? Try using different names.
    – muru
    Feb 20, 2016 at 10:20
  • In fact, the problem arise only when using the etnadji/vim-epub plugin for epub editing. I'll live with that ! Thanks.
    – hutou
    Feb 20, 2016 at 17:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .