back to Today I Learned page

VIM - Make spaces and tabs visible

posted at 12-07-2023

I usually use VIM to code, and sometimes I have problems finding indentation or some random spaces in the end of a line.

Googled a bit today and found out about list in VIM. In which enables the strings to use in 'list' mode and for the :list command. So, instead of shows just an empty space, it will show a character instead (this is configurable, and below I show how to do it).

For you to configure this, you need to set listchars and add some parameters.

Parameters that I'm using:

eol:$ End of line, the end of the line will show $
space:- Each space will be a dash - instead of whitespace
tab:># Each tab will show >###### instead of a big whitespace
trail:~ Trailing spaces, it will show ~ instead of the amount of spaces given

So if we go inside vim and do the following:

:set listchars=eol:$,space:-,tab:>#,trail:~
:set list

A normal text like the first two paragraphs will be:


It might be a little bit too noisy, so I created an alias to enable and disable that on ~/.config/nvim/init.vim (I use neo vim).

You can find how to do that here: