VIM中文显示设置

1 问题描述及解决

系统locale是zh_CN.UTF-8,用了我以前的配置文件,终端下运行VIM却出现乱码情况。互联网搜索一番,发现解决方案其实很 简单,在vimrc里面设置好encoding、fileencoding、termencoding的值即可。
我原始配置文件关于CJK支持方面的设置如下(非原创):

" Multi-encoding setting, MUST BE IN THE BEGINNING OF .vimrc!
if has("multi_byte")
  " When 'fileencodings' starts with 'ucs-bom', don't do this manually
  "set bomb
  set fileencodings=ucs-bom,utf-8,cp936,taiwan,japan,korea,latin1
  " CJK environment detection and corresponding setting
  if v:lang =~ "^zh_CN"
    " Simplified Chinese, on Unix euc-cn, on MS-Windows cp936
    set encoding=cp936
    set termencoding=cp936
    if &fileencoding == ''
      set fileencoding=cp936
    endif
  elseif v:lang =~ "^zh_TW"
    " Traditional Chinese, on Unix euc-tw, on MS-Windows cp950
    set encoding=taiwan
    set termencoding=taiwan
    if &fileencoding == ''
      set fileencoding=taiwan Continue reading ‘VIM中文显示设置’ »

点击量:46