16

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?

3
  • 3
    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:!·). Aug 13, 2015 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. Aug 13, 2015 at 8:28
  • 1
    As a worthy note, I've actually ended up using a tiny arrow for my tabs. Not as intrusive. Mar 29, 2016 at 23:32

2 Answers 2

29

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

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

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
  • 2
    That's a lot of trouble when you could do set listchars=tab:\ \ ,....
    – romainl
    Aug 13, 2015 at 7:27
  • 1
    @romainl then make an answer :) Aug 13, 2015 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.