vim如何浏览gb2312编码的文件

277 views
Skip to first unread message

jazzi

unread,
Oct 14, 2006, 11:35:56 AM10/14/06
to Vim.cn
用VIM打开fcitx的配置文件全是乱码,中文全都无法正确显示
请问有什么办法吗?

tocer

unread,
Oct 14, 2006, 11:41:24 AM10/14/06
to Vim...@googlegroups.com
试试
:set encoding=gb2312

jazzi wrote::
> 用VIM打开fcitx的配置文件全是乱码,中文全都无法正确显示
> 请问有什么办法吗?
>
> >

Xiaoyu Peng

unread,
Oct 14, 2006, 9:22:29 PM10/14/06
to Vim...@googlegroups.com
On Sat, Oct 14, 2006 at 08:35:56AM -0700, jazzi wrote:
> 用VIM打开fcitx的配置文件全是乱码,中文全都无法正确显示
> 请问有什么办法吗?

打开后用 :edit ++enc=cp936

>
> >

DaVinci

unread,
Oct 15, 2006, 11:01:29 PM10/15/06
to Vim.cn

edit++enc=gb2312

Zhang Lei

unread,
Oct 16, 2006, 12:46:02 AM10/16/06
to Vim...@googlegroups.com
将下面的配置加入 vimrc 试试

" multi-encoding setting
if has("
multi_byte")
  "
set bomb
  set fileencodings
=ucs-bom,utf -8,cp936,big5,euc -jp,euc-kr, latin1
  
" CJK environment detection and corresponding setting
  if v:lang =~ "
^zh_CN"
    "
Use cp936 to support GBK, euc-cn == gb2312
    set encoding
=cp936
    set termencoding
=cp936
    set fileencoding
=cp936
  
elseif v:lang =~ "^zh_TW"
    " cp950, big5 or euc-tw
    "
Are they equal to each other?
    
set encoding=big5
    set termencoding
=big5
    set fileencoding
=big5
  
elseif v:lang =~ "^ko"
    " Copied from someone's dotfile, untested
    set encoding=euc-kr
    set termencoding=euc-kr
    set fileencoding=euc-kr
  elseif v:lang =~ "
^ja_JP"
    "
Copied from someone's dotfile, untested
    set encoding=euc-jp
    set termencoding=euc-jp
    set fileencoding=euc-jp
  endif
  " Detect UTF-8 locale, and replace CJK setting if needed
  if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
    set encoding=utf-8
    set termencoding=utf-8
    set fileencoding=utf-8
  endif
else
  echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"
endif


--
Best Regards,
zlbruce

danranx

unread,
Oct 22, 2006, 9:53:19 AM10/22/06
to Vim.cn
在 ~/.vimrc 中加入:

set encoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese

再重新打开就可以了。

Reply all
Reply to author
Forward
0 new messages