vimrc: Set UTF-8 as vim's default encoding for commit messages
commitee24d5bdc056e09bb0517b71f9239d0aa36b385a
authorAtsushi Nakagawa <atnak@chejz.com>
Wed, 7 Dec 2011 16:18:44 +0000 (7 10:18 -0600)
committerAtsushi Nakagawa <atnak@chejz.com>
Sun, 11 Dec 2011 05:23:28 +0000 (11 14:23 +0900)
tree56cf8b3a56a99c2061803363152b741176f7bb27
parent27e57a1e660fcc49b53afe272f698dcd1894404f
vimrc: Set UTF-8 as vim's default encoding for commit messages

We avoid setting `encoding' and `termencoding', and opt to only setting
`fileencodings' because it's understood that vim sets the former two to
the user's system's "ANSI" and "OEM" code pages (setting either both if
they differ or only `encoding' if they're the same) [1].  The setting of
"OEM" is particularly significant as it is required for native characters
to be correctly displayed on the user's console [2].

We set "utf-8" as the only value of `fileencodings', there by making it
the default encoding used to save new commit messages to COMMIT_EDITMSG.
This is consistent with what git expects in an environment where the
user has not altered the value of `i18n.commitencoding'.

When loading an existing message, for operations such as 'commit --amend'
and 'rebase -i', our setting for `fileencodings' means that vim will first
attempt to load it as UTF-8 and then fallback to the encoding set by
`encoding' if unable to do so.  This encoding is expected to be "ANSI",
as mentioned above, and this side-effect is of benefit if the user does
have an altered value of `i18n.commitencoding'.  (Here, we're assuming
users not set this, if at all, to anything other than that of "ANSI"
because that is thought to be the most natural for their location.)

Users SHOULD unset `i18n.commitencoding' after this is released.  However,
failing to do so may not show any visible regressions.  (See tests for
case #2 at [3].)

This patch follows the discussion in the [4] link.

[1] http://groups.google.com/group/msysgit/msg/be6218f1cbf5e747
[2] http://groups.google.com/group/vim_dev/msg/3dd77f3014a60e43
[3] http://groups.google.com/group/msysgit/msg/508cca8b57f00546
[4] http://groups.google.com/group/msysgit/msg/55c582fb1b279d08
share/vim/vimrc