vim E213: Cannot convert (add ! to write without conversion)

Subject:Re: vim 6.2 - encodings
From:Antoine J. Mechelynck (anto@belgacom.net)
Date:May 28, 2004 11:37:56 am
List:com.googlegroups.vim_use

ji@altern.org wrote:

Hi there,

I'm playing around with encodings in gvim62 (on winxp). Based on thescript set_utf8.vim by Antoine athttp://vim.sourceforge.net/scripts/script.php?script_id=789, I'veadded the following lines to my _vimrc :

if &termencoding == ""

 let &termencoding = &encoding

endif

if exists("+printencoding") && (&printencoding == "")

  let &printencoding = &encoding

endif

set fileencodings-=ucs-bom

set fileencodings-=utf-8

if (&fileencodings == "") && (&encoding != "utf-8")

 let &fileencodings = &encoding

endif

set fileencodings^=ucs-bom,utf-8

set encoding=utf-8

setglobal fileencoding=utf-8

setglobal bomb

Here's my problem :

o create a new file (which by default is utf-8 encoded)

o close this fileo reopen the file (fileencoding is recognised as utf-8)

o :set fenc=ucs-bom

o :w

o I got error E213: Cannot convert (add ! to write withoutconversion)

What am I doing wrong ?

Thanks in advance.

Cheers /jerome

1) "ucs-bom" is not a real encoding. it is not valid in 'fileencoding'(singular), but it is valid in 'fileencodings' (plural), to tell (g)vim torecognise all Unicode encodings when a "byte-order-mark" is present at thebeginning. (The byte-order-mark is code point U+FEFF "zero-width no-breakspace", which is represented by a different byte sequence in each of thevarious Unicode encodings, and each of whose representations is illegal inall Unicode encodings other than its own, with the exception that the BOMfor UCS-4le is equivalent to the sequence <FEFF><0000> in UCS-2le, so itmust be "assumed" that a file in UCS-2le will not have a null as its first"real" character.

2) If what you want to do is set a BOM at the head of your UTF-8 file, youshould have nothing to do ("setglobal bomb" takes care of that). To makesure of whether it is there or not, use ":setlocal bomb?" (without thequotes, but with the question mark). Vim should answer either " bomb" or"nobomb".

3) To place or remove a BOM on *any* Unicode file, set or unset 'bomb'(respectively).

See :help 'fileencoding' :help 'fileencodings' :help 'bomb'

HTH,Tony.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值