brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: set list in Vim shows tabs and trailing spaces

Vim
~/tips/tip-vim-set-list

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

Makes invisible whitespace visible while you edit.

Is that indent a tab or four spaces? Is there a space after the last word? With :set list Vim shows you.

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

list switches the display on, and listchars decides what each invisible character looks like. Here a tab becomes >---, filling its whole width, trailing spaces show as ~, and every line ends in $. The file itself is not changed, this is only how Vim draws it.

The default listchars is just eol:$, which marks line ends but shows a tab as ^I. That is why setting listchars yourself makes the option far more useful.

I’d put a quieter version in a vimrc and leave eol out, since a dollar on every line gets noisy:

set listchars=tab:»\ ,trail:·,nbsp:␣

The nbsp entry is a good one for anything copied from a web page, where non breaking spaces hide.

Turn it off again with :set nolist, or toggle it with :set list!.

Further reading: Vim help: 'list', Vim help: 'listchars'

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Vim tips :%s/<Ctrl-r><Ctrl-w>/newname/g /oldname find . -name "*.conf" | vim – vim --clean file.txt :set textwidth=72 All Vim tips (45) All topics

Link