I use list and listchars to show my whitespace, but the code style I adhere to uses tabs. Seeing > or ^I for all of my tabs is nauseating.

How would I keep all of my existing list characters but with a blank tab character?

  • 2
    Note that setting a space as a tab means you won't be able to distinguish between spaces and tabs, or see tabs in other places (like inside a string, end of the line). It sort of defeats the purpose of set list ;-) Some other (smaller) character you may try: · (MIDDLE DOT), (OPEN BOX) or (SUBSCRIPT MINUS). (I personally use: set listchars=tab:!·). – Martin Tournoij Aug 13 '15 at 8:28
  • @Carpetsmoker correct. This is why I have a linter. :) Exclamation point might not be so bad, I suppose I could play around with them. – Qix - MONICA WAS MISTREATED Aug 13 '15 at 8:28
  • 1
    As a worthy note, I've actually ended up using a tiny arrow for my tabs. Not as intrusive. – Qix - MONICA WAS MISTREATED Mar 29 '16 at 23:32

'listchars' takes two characters for tab so you can simply use two regular spaces:

set listchars=tab:\ \ ,trail:·,eol:¬,nbsp:_
  • 1
    Didn't know you could do \ , though it makes sense since you can search with them (/\ ). I was trying \s, ' ', etc. – Qix - MONICA WAS MISTREATED Aug 13 '15 at 7:33

Turns out non-breaking spaces work just fine.

As per this answer, the utf-8 sequence is "\xc2\xa0".

Since I'm on a mac, I simply did echo -en "\xc2\xa0" | pbcopy and then added them to my .vimrc:

set listchars=tab:[2p],...

where [2p] pasted the clipboard twice. The result ended up being

set listchars=tab:<nbsp><nbsp>,...

which correctly caused tabs to show up as simple whitespace.

  • 2
    That's a lot of trouble when you could do set listchars=tab:\ \ ,.... – romainl Aug 13 '15 at 7:27
  • 1
    @romainl then make an answer :) – Qix - MONICA WAS MISTREATED Aug 13 '15 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.