Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the set list and set listchars options in vim. I'd like to customize set listchars to display trailing spaces, etc., but not tabs. Is it possible to specify that I don't want a particular type of whitespace displayed?

I've tried this:

set listchars=tab:,trail:·,extends:>,precedes:<,nbsp:%

But I got a syntax error when loading my .vimrc.

share|improve this question

That's not possible, unfortunately. You can only :set list on or off, and for those elements you don't define in 'listchars', the defaults will be used.

I would not recommend to always operate under :set list, as it has some side effects (e.g. affecting soft wrapping).

If you're just concerned about highlighting trailing whitespaces, there are plugins that do this through other means. Actually, I have written the ShowTrailingWhitespace plugin for that; the page has links to alternatives.

share|improve this answer
up vote 3 down vote accepted

I just discovered that although this is technically not possible, one can cheat and enter special Unicode whitespace characters (not the regular space character) as the character to display for a tab. Although this still uses vim's hl-NonText highlighting color, it's certainly less obtrusive.

In other words, do this (or similar):

set listchars=tab:  ,trail:·,extends:>,precedes:<,nbsp:%

The two characters after tab: are not regular space characters - they are U+2002. You can enter them in vim itself with Ctrl-V u 2 0 0 2 (in insert mode).

So far, I haven't noticed any nasty side-effects.

share|improve this answer
Why not simply use spaces? set listchars+=tab:\ \ – Nikita Kouevda Jul 5 '13 at 0:07
@NikitaKouevda, I didn't know you could escape spaces like that. That works too. If you state that as answer, I'll mark it correct. – Andrew Ferrier Jul 7 '13 at 23:17

You must log in to answer this question.

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