tags:

views:

3765

answers:

6

I can't find a way to make Vim show all white spaces as a character. All I found was about tabs, trailing spaces etc.

+10  A: 

:set list will show all whitespaces as a character. Everything but a space will look different than its normal state, which means that if you still see a plain old space, it's really a plain old space. :)

Ether
+1  A: 

You could use

:set list

to really see the structure of a line. You will see tabs and newlines explicitly. When you see a blank, it's really a blank.

tangens
+21  A: 

As others have said, you could use

:set list

which will, in combination with

:set listchars=...

display invisible characters.
Now, there isn't an explicit option which you can use to show whitespace, but in listchars, you could set a character to show for everything BUT whitespace. For example, mine looks like this

:set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<

so, now, after you use

:set list

everything that isn't explicitly shown as something else, is then, really, a plain old whitespace.

ldigas
+4  A: 

Just a trick. If you set:

:highlight Search cterm=underline gui=underline

and then perform a search for a space then every space character will be shown as an underline character.

mrucci
+6  A: 

:set list to enable.

:set nolist to disable.

Marcin
A: 

If by whitespaces you mean the ' ' character, my suggestion would just be a search/replace. As the others have hinted, set list changes non printing characters to a visible character that's configured in listchars.

To explicitly show spaces as some other character, something similar to the below should do the trick:

:%s/ /█/g

Then just undo the change to go back again.

(to get the █ I pressed this exact key sequence: :%s/ /CTRL-KFB/g)

Randy Morris