3

In (mac)vim I use the following .vimrc

set guifont=Meslo_LG_M_Regular_for_Powerline:h12
set encoding=utf-8

When I write a € sign in the buffer and try to save it, I always get an error

CONVERSION ERROR in line xxxx

This appears as well on some type of dashes. As workaround I have to replace the signs, e.g. € -> EUR and than it will work fine to save the file. But this is annoying.

How can I get vim to write the € so that I can save the file without error messages?

Thats what I use:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 21 2014 14:54:22) MacOS X (unix) version ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G1510

jerik
  • 5,714
  • 8
  • 41
  • 80

1 Answers1

2

With your 'encoding' setting, Vim is able to represent the € sign internally. Buffers loaded into Vim for editing still have a particular 'fileencoding'. If that one cannot represent the character (e.g. if it is latin1), you'll get the conversion error.

A quick fix is to force saving in UTF-8, e.g. via :w ++enc=utf-8.

Better adapt the global 'fileencodings' setting so the the file gets detected right from the start. Note: 'fileencodings' is the global option controlling the detection, 'fileencoding' is the actual, buffer-local encoding used.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324