Articles: Fix for Vim Weird "Â" Character Appearing When You Type/Paste ASCII Character

Posted by: david on 11/04/2010 - 06:42 PM
I was editing some files with vim on a new Linux server and was getting frustrated that everytime I try to type in or paste in the British Sterling/British pound symbol of £ it is prefixed with a strange character of Â. I did not have this problem with the pervious server I was using, which is based on FreeBSD. And when I tried to delete that character it deletes the £ character as well.

After almost pulling my hair out, I just figured out that it is an issue with character encoding in Vim.

If you type:

:set encoding

Vim will tell you the current encoding being used. So I typed that in Vim on the old FreeBSD server and it showed:

encoding=latin1

And when I did the same on the new Linux server in Vim, it showed:

encoding=utf-8

By default, apparently the install in Linux for Vim uses UTF-8 unicode. But I wanted encoding, which worked for me, so in my .vimrc file I entered:

:set encoding=latin1

And voila- no more oddball  character weirdness.