Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1324309
  • 博文数量: 334
  • 博客积分: 10302
  • 博客等级: 上将
  • 技术积分: 2986
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-12 10:17
文章分类

全部博文(334)

文章存档

2013年(1)

2012年(9)

2011年(4)

2010年(10)

2009年(24)

2008年(64)

2007年(72)

2006年(150)

我的朋友

分类: 系统运维

2008-01-14 22:20:56

Windows 的 gvim 要編 UTF-8 要做的設定..
設 .vimrc
不過我記得預設是 UTF-8 讀都沒有問題..
寫也可以.. 不過寫完後是存 Big5 的編碼..

設定檔如下

轉載自

" piaip's gvim settings for gvim/win32 with UTF8
" optimized for Traditional Chinese users
" last update: Mon Jun 7 17:59:54 CST 2004

let $LANG="zh_TW.UTF-8" " locales
set encoding=utf-8 " ability
set fileencoding=big5 " prefer
" charset detect list. ucs-bom must be earlier than ucs*.
set fileencodings=ascii,ucs-bom,utf-8,ucs-2,ucs-le,sjis,big5,latin1

" for console mode we use big5
if has("gui_running")
set termencoding=utf-8
else
set termencoding=big5
endif

" vim:ft=vim
==========================
根據 myhsu 的問題做的測試.
gvim 如果不設 set fileencoding=utf-8
預設就會存成 big5,
如果 設定 set fileencoding=utf-8
存檔就會存成 utf-8

如果檔案本身就是 utf-8.
在 gvim 編輯後.. 還是會存成 utf-8.. 不會存成 big5
(gvim 自動判斷)
==========================
UTF-8 Big5 皆可讀取的設定
"============utf8 ===============
" piaip's gvim settings for gvim/win32 with UTF8
" optimized for Traditional Chinese users
" last update: Mon Jun 7 17:59:54 CST 2004
"let $LANG="zh_TW.UTF-8" " locales
"set encoding=utf-8 " ability
"set fileencoding=big5 " prefer
" charset detect list. ucs-bom must be earlier than ucs*.
"set fileencodings=ascii,ucs-bom,utf-8,ucs-2,ucs-le,sjis,big5,latin1
" for console mode we use big5
" == 下面這三行是主要的
" 參考自 的 Vim區
set fileencodings=utf-8,big5,euc-jp,gbk,euc-kr,utf-bom,iso8859-1
"set encoding=utf8
set tenc=utf8
" == encoding 不要設的話. menu bar 就不會變亂碼.

if has("gui_running")
set termencoding=utf-8
else
set termencoding=big5
endif
" vim:ft=vim
"============utf8 ===============
不過設完後記事本存的 UTF-8 檔還是會有亂碼.
因為記事本會自己在 UTF-8 檔前面加 BOM(就是些怪東西).
造成還是無法看.. 不過除了記事本外的都沒有問題就是了 :)
===============================
目前 Windows 的 .vimrc 檔完整內容.
======
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
if &sh =~ '\ silent execute '!""C:\Program Files\Vim\vim63\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . '"'
else
silent execute '!C:\Program" Files\Vim\vim63\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
endif
endfunction

"set fileencoding=taiwan
"set fileencoding=utf-8
"set guifontset=8x16,kc15f,-*-16-*-big5-0
set cindent
set smartindent
"set backup
"set backupdir=~/.bak
set backupdir=D:\bak
"set enc=taiwan
set hls
set nocompatible
set sw=3
set showmatch
set background=light
set nu
colorscheme desert
syntax on
set guifont=mingliu:h12

highlight Comment ctermfg=darkcyan
highlight Search term=reverse ctermbg=4 ctermfg=7
highlight Normal ctermbg=black ctermfg=white
" Necessary. This setting tells vim to load latex-suite
" when a tex file opened.
filetype plugin on
" Optional. This enables automatic indentation as you
" type.
filetype indent on

"============utf8 ===============
" piaip's gvim settings for gvim/win32 with UTF8
" optimized for Traditional Chinese users
" last update: Mon Jun 7 17:59:54 CST 2004
"let $LANG="zh_TW.UTF-8" " locales
"set encoding=utf-8 " ability
"set fileencoding=big5 " prefer
" charset detect list. ucs-bom must be earlier than ucs*.
"set fileencodings=ascii,ucs-bom,utf-8,ucs-2,ucs-le,sjis,big5,latin1
" for console mode we use big5
set fileencodings=utf-8,big5,euc-jp,gbk,euc-kr,utf-bom,iso8859-1
"set encoding=utf8
set tenc=utf8

if has("gui_running")
set termencoding=utf-8
else
set termencoding=big5
endif
" vim:ft=vim
"============utf8 ===============
======

阅读(2406) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~