Error detected while processing vimrc error when using UTF-8 characters in listchars variable

This error stumped me for a while, and I didn’t find any good answers on Google, so hopefully this can help someone else. I’m running gVim 7.2 on Windows – this information may not apply to other versions/platforms.


I’ve been slowly adding more functionality to my vimrc file. Today I learned about the listchars setting, which allows you to choose what placeholders to use when displaying whitespace (taking the tip from Configuring Vim right).

For my “trail” setting (spaces at the end of a line), I picked the Middle Dot Unicode character · (U+00B7 or RightAlt+0183). When I saved (:w) and reloaded the new settings (:so ~_vimrc), the setting took effect with no problem. However, when I closed gVim and re-opened it, I was greeted with the error message “Invalid argument: listchars…”



After much trial an error, I determined that my _vimrc file must be encoded as UTF-8 with Signature. It was previously encoded as UTF-8 (w/o Signature) – which is how gVim encodes the default file. To fix it, I opened _vimrc in my old favorite Notepad2, clicked on the UTF8 in the status bar, selected UTF-8 Signature, and saved the file. The next time I started gVim, there was no error, and my trailing whitespace displayed with the Middle Dot.

Update: A comment from John Weldon suggested a much simpler solution that you can do with vim (no Notepad2 required).

(Optional) If it isn’t already UTF-8 (mine was), set the encoding:

:set fileencoding=utf-8

Tell vim to store the encoding signature:

:set bomb

And of course :w to save the file.

This entry was posted in vim. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • You can also save the file in vim by using:

    :se bomb

    to add the utf-8 signature to the file.

  • Awesome – thanks John, that’s a much simpler solution. I’ll update the post.

  • You’re welcome :)