I'm currently trying to switch from gedit to vim. I try to make vim look similar to gedit:

Especially, I would like to show spaces with dots.

I currently have:

There are some differences, but it looks quite similar (this is my current .vimrc file). But I don't get those dots for spaces.

How can I make vim show spaces?

I found some answers (like this one) that seem to suggest to replace spaces by a special visible character and then replace it back. I don't want to do this every time. I want to be able to open vim and see those spaces.

7 Answers
7

Vim provides the 'listchars' option to show Tab vs. Space, and space characters in critical places, i.e. trailing at the end of lines. It does not offer a modification for all spaces: a blank square is a space, period.

If you're not happy with the workarounds posted in the referenced question, there's no way to achieve this other than modifying Vim's source code and compiling your own binary.

While you can't do exactly what you want here, if your reasoning is like mine, you're wanting to see those spaces because it helps verify proper indentation (do I have 2 spaces there, or is it 3?). For Vim >= 7.3, you can use the indentLine plugin to add a marker at each indentation. It's awesome.

There are times when I absolutely need to see which whitespaces are tabs and which are true space characters, as well as when spaces appear at the end of a line.

When I'm using vim, I use:

:set list

(which I can turn off with :set nolist)

With :set list, literal spaces show up as spaces, tabs show up as ^I, and the end-of-line shows up as a bright-pink $. (So any blank space you see to the left of the pink $ you'll know is a true space character, and the blank spaces to the right of it is just the "nothing" between the end-of-line and the right side of the editor.)

It's ugly, but it works well.

I don't recommend using it all the time -- just those times when it is crucial to see where literal spaces and literal tab characters exist.

I came across this question, because I wouldd like to show leading spaces (indent spaces).
The above mentioned plugin indentLine is the solution for that Problem.
If you use Vundle as plugin manager you can add Plugin 'Yggdroot/indentLine' to your .vimrc and then run vim +PluginInstall +qall to install the plugin.

Add the following two lines to your .vimrc to show leading spaces as ·.