Subscribe for free with iTunes, Twitter, or RSS (Ogg or Quicktime).

Vimcasts

Show invisibles

#1

Vim’s list feature can be used to reveal hidden characters, such as tabstops and newlines. In this episode, I demonstrate how to customise the appearance of these characters by tweaking the listchars setting. I go on to show how to make these invisible characters blend in with your colortheme.

Download

OGG 4.8 MB

Quicktime 5 MB

Put the following in your .vimrc file:

" Shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>

" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬

If you like, you can customise other invisible characters besides tabs and end-of-lines. For more information, run :help listchars.

You can customise the syntax highlighting colours of invisible characters with the NonText and SpecialKey keywords. In my prefered colourtheme, I have added the following lines:

"Invisible character colors 
highlight NonText guifg=#4a4a59
highlight SpecialKey guifg=#4a4a59

Unicode characters can be inserted by typing ctrl-vu followed by the 4 digit hexadecimal code.

Symbol Unicode Name
¬ U+00AC not sign
U+25B8 black right-pointing small triangle
U+2620 skull and crossbones
U+2764 heavy black heart
U+203d interobang

Further reading