How do I customize which invisible characters are shown in list mode, including trailing spaces and off-screen indicators?
Answer
:set listchars=
Explanation
The listchars option controls exactly which invisible characters Vim highlights when list mode is active. Beyond the commonly known tab and trail, it includes a full set of indicators for off-screen content, end-of-line markers, non-breakable spaces, and every plain space — each configurable with any Unicode symbol.
How it works
:set listactivates display of invisible characters:set listchars={key}:{char},...configures what is shown for each type- Unset keys keep their defaults; you only need to configure what you want
The full set of keys:
| Key | Shows |
|---|---|
tab |
Tab characters (use two chars: leader + fill) |
trail |
Trailing spaces |
space |
Every space character |
eol |
End-of-line marker |
extends |
Character shown on the right when the line extends past the screen |
precedes |
Character shown on the left when the line extends before the screen |
nbsp |
Non-breaking spaces (\u00a0) |
conceal |
Replacement for concealed text |
Example
A practical configuration for code review:
:set listchars=tab:»·,trail:·,extends:›,precedes:‹,nbsp:⎵
This highlights:
»·— tab (arrow head + dot fill)·— trailing spaces (a common source of merge noise)›/‹— text that scrolls off-screen innowrapmode⎵— non-breaking spaces that look like regular spaces but break alignment
Tips
- Set
extendsandprecedesbefore using:set nowrapso you always know when content is off-screen - Enable
trailglobally in yourvimrcto catch accidental trailing whitespace while editing - Use
:set nolistorset list!to toggle on/off without losing the configuration :set listchars=space:·can be noisy; prefertrailalone unless you specifically want to see all spaces