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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityI 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?
'listchars'
takes two characters for tab
so you can simply use two regular spaces:
set listchars=tab:\ \ ,trail:·,eol:¬,nbsp:_
\
, though it makes sense since you can search with them (/\
). I was trying \s
, ' '
, etc.
Aug 13, 2015 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.
set listchars=tab:\ \ ,...
.
set list
;-) Some other (smaller) character you may try:·
(MIDDLE DOT),␣
(OPEN BOX) or₋
(SUBSCRIPT MINUS). (I personally use:set listchars=tab:!·
).›