Plurrrr

Fri 01 Apr 2022

Making whitespace visible in Vim

Now and then I use vim at $work. Because I wanted whitespace to be visible I added the following to my ~/.vimrc:

set list
set listchars=eol:⏎,tab:⍿·,trail:×

Note that this also makes trailing whitespace visible, which I prefer.

Vim with whitespace made visible
Vim with whitespace made visible.

In the above screenshot, showing an example listing from Java The Complete Reference Twelfth Edition by Herbert Schildt; page 188-189, you can clearly see the whitespace. I use tabs to indent 4 characters. Also, there is some trailing whitespace, marked by the × characters at the line with the cursor at the end.

Note, however, that if you copy paste using the mouse the characters representing whitespace are included. To prevent this, list has to be toggled off. I bound F12 to toggling list by adding the following to my ~/.vimrc:

map <f12> :set list!<cr>