From 6017a8db8831fb4b0a0240985602a07432be9355 Mon Sep 17 00:00:00 2001 From: Atsushi Nakagawa Date: Wed, 7 Dec 2011 10:18:44 -0600 Subject: [PATCH] Use UTF-8 encoding for commit messages in vim Set vim's default and assumed encodings for saving and loading commit messages to "utf-8". Since our vimrc contains no other encoding settings, the outcome is expected to be "encoding=ACP termencoding=ACP fileencoding=utf-8". Where ACP is the multibyte codepage that's native to the user's system (for example, "ascii" on an English system and "cp932" on a Japanese). `encoding' gets its value from vim, `termencoding' implicitly from `encoding' and `fileencoding' becomes the only available value in our setting of `fileencodings'. The value of ACP for `termencoding' needs to be retained because that's the only encoding that current versions of vim support for displaying characters native to the user's system[1]. On the other hand, `fileencoding' needs to be "utf-8" because that's the expected encoding for git's "COMMIT_EDITMSG" file. This patch follows the discussion in the [2] link. [1] http://groups.google.com/group/vim_dev/msg/3dd77f3014a60e43 [2] http://groups.google.com/group/msysgit/msg/55c582fb1b279d08 --- share/vim/vimrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/vim/vimrc b/share/vim/vimrc index 0d8cd4da..8867f0e5 100644 --- a/share/vim/vimrc +++ b/share/vim/vimrc @@ -17,6 +17,9 @@ set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(ex "------------------------------------------------------------------------------ " Only do this part when compiled with support for autocommands. if has("autocmd") + "Use UTF-8 for commit messages + autocmd BufReadPre COMMIT_EDITMSG setlocal fileencodings=utf-8 + "Remember the positions in files with some git-specific exceptions" autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") -- 2.11.4.GIT