My .vimrc contains:

if $LANG =~ '\(UTF\|utf\)-\?8' || $LC_CTYPE =~ '\(UTF\|utf\)-\?8'
  set list listchars=tab:»·,trail:~,extends:>,precedes:<

But there is some chars which is unicode, when I run vim under LC_CTYPE=zh_TW.Big5 environment, it will show

Error detected while processing /home/user/.vimrc:
  line   70:
E474: Invalid argument: listchars=tab:»·,trail:~,extends:>,precedes:<

Add the following line to your vimrc, preferably near the beginning:

scriptencoding utf-8

That will tell vim to read the file as UTF8 even if you're on a non-UTF system. It will then transcode any characters from that into your current encoding. If the characters you're using in the listchars option exist the other encodings that you use you shouldn't even need to have the conditional around that.

  • This method works on vim, but, I found gvim still shows that error message. – Daniel YC Lin Feb 25 '13 at 5:11
  • Do you have a .gvimrc file that also contains unicode characters? If so, adding the same line to that file should fix the problem there as well. That command only applies to the file in which it is found, so would need to be included in any vim configuration file where the character encoding is important. – qqx Feb 25 '13 at 15:39
  • I found the problem caused by my gvimrc and fixed it. – Daniel YC Lin Feb 27 '13 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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