"A.J.Mechelynck" <[EMAIL PROTECTED]> 写于 2007-06-06 10:30:54:
> > 1. will vim write BOM when writing to unicode files? or is there any
> > options for that?
>
>    :setlocal bomb
>
> When opening a Unicode file, Vim will set or clear the buffer-local
'bomb'
> option according to the presence or absence of a BOM. That option is
> irrelevant for non-Unicode files. You can also set or clear it manually.
When
> creating a new Unicode file from scratch, a BOM will be set, or
not,depending
> on the corresponding global setting, so if you want your new Unicode
files to
> be created with a BOM, you may add
>
>    :setglobal bomb
>
> to your vimrc.

Thanks, it seems that BOM is not written by default and can be set only
globally for all unicode encoding.

But the problem is: my gcc 4.0 will complain about BOM for utf-8 source
file, while ucs-2le must have a BOM so that vim can recognize it without
adding the ucs-2le in fencs (ucs-2le should never be added into fencs
though, since most characters in cpxxx are valid and it is likely to mess
things up).

Is there anyway to do BOM setting only for particular unicode encoding like
the following?
when write utf-8 files, do not write the BOM.
when write ucs-2 files, write the BOM. (it should happen even if the file
opend as utf-8 then :set fenc=ucs-2le and then :write)

--
Sincerely, Pan, Shi Zhu. ext: 2606

Reply via email to