My goal were to somehow make visible, if a whitespace is space, tab, or even newline (and, ideally, in case of newline I would be happy to see \r\n and \n differently).

I am thinking to a similar thing as the GUI text editors can do.

Is it somehow with Vim also possible?


2 Answers 2


Yes, look at :help listchars.

listchars is a string that will be parsed when list is set to determine what to render for certain special characters. You can set listchars in your .vimrc like so:

set listchars=eol:!,tab:>=,trail:.
set list

This will use the ! character to show the end of every line, tabs like >=== (assuming four-space tabs), and trailing spaces with a . character. The characters are highlighted with the SpecialKey group.

In addition, you can include the following tokens in listchars:

  • extends:<character> for the last character in a long line
  • precedes:<character> for the first character in a long line
  • conceal:<character> for concealed text
  • nbsp:<character> for non-breaking spaces

Note that you cannot get vim to display visible whitespace for spaces that are not trailing without a relatively modern version of vim; check if has("patch710") to see if space is supported in listchars.


This can be done with :set list. The Characters displayed for the different whitespace chars can be controlled by :set listchars. See the help topics for detailed information. Here's an example from my .vimrc:

set list
set listchars=tab:>-,trail:.,extends:#,nbsp:.
  • great. And how can I change the color of the markers thus shown? At the moment they're blue. Would like light grey or something off-white. Guessed "listcolor" but no.
    – projix
    Jan 13, 2020 at 13:50
  • @projix I have not tested it but this answer shows how to change the colors: vi.stackexchange.com/a/6140/117 - tl;dr set the highlight colors for the respective highlight classes "NonText" and "SpecialKey".
    – l4mpi
    Jan 14, 2020 at 15:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.