[Python-Dev] PEP 263 -- Python Source Code Encoding

jepler@unpythonic.dhs.org jepler@unpythonic.dhs.org
Tue, 26 Feb 2002 15:01:43 -0600

On Tue, Feb 26, 2002 at 08:50:35PM +0100, M.-A. Lemburg wrote:
> Does anybody know where XEmacs is moving w/r to this ? (and
> for that matter what about vi, vim, etc. ?)

I'm working with Vim 6.0, 20001 Sep 14.

VIM lets you set variables with text similar to
Apparently you would use
to select shift-jis encoding.  In the vim style, it seems most common to
place this at the bottom of a file, but it can be placed at the top too.
The variable "modelines" controls how many lines at each end of the file is
inspected, with the default being 5.  It's documented that the form
	vi:set KEY=VALUE:
may be compatible with "some versions of Vi" but does not say which.  (I
can't get this to work)

You can set a list of encodings to attempt when a file is loaded, which
defaults to "ucs-bom,utf-8,latin1".  A user who wanted to treate
non-unicode files as shift-jis by default would
	:set fileencodings=ucs-bom,utf-8,sjis
You can also load a particular file with the ++enc parameter:
	:edit ++enc=koi8-r russian.txt
(I can get this to work, but I have to do it manually to load anything in
an odd character set)

The emacs line is harmless in vim, but doesn't do anything.  It's possible
that using :autocmd someone could make vim use the emacs line to set
encoding, but I'm not sure -- setting fileencoding after a file is loaded
seems to perform a translation from the old characterset to the new.