2009/08/13

VIM unicode

在 MS Windows 下面由于受 Byte Order Mark (BOM) 的控制, 需要对GVIM 做一些配置才能正常工作。 这包括 tenc, enc, fencs, guifont, guifontwide。 这样一来,vim就可以自动 根据BOM做出正确的显示了,同时也可以自动识别GBK和BIG5。


if has("multi_byte")
set encoding=unicode
let &termencoding = &encoding
" Set default encoding as UTF-8 with BOM
setglobal fileencoding=utf-8 bomb
" Auto detect the file encoding BOM unicode, utf-8, GBK, Big5, Latin1
set fileencodings=ucs-bom,utf-8,cp936,cp950,latin1

" Walkaround the encoding problem for fenc=utf-8 && enc=ucs-2
augroup i18n
autocmd!
autocmd BufReadPost * if &fileencoding == "utf-8" | let &encoding = &fileencoding | endif
augroup END
endif

" Enable the Chinese characters
"set guifont=Bitstream\ Vera\ Sans\ Mono:h10:cANSI,NSimSun:h11:cGB2312
set guifont=Consolas:h11:cANSI,NSimSun:h11:cGB2312
set guifontwide=NSimSun:h11:cGB2312
发表评论