12/10/2007

Leopard,Terminal,Vim,and .... UTF-8

最近買了新的 MacBook ,Leopard 到目前感覺都還很不錯,尤其是大幅度改進的 Terminal.app 。不過,跟我預料的一樣,Terminal 的 UTF-8 問題依舊沒有設定好。所以花了點時間 survey ,順便把一直困擾我的 vim 中文問題一起解決。

Leopard 內建的 vim 是 version 7.0.234 ,GNU bash 是 3.2.17 ,這幾個版本支援 UTF-8 都沒有任何問題,所以其實只是設定檔的問題。

1. 修改 ~/.profile
加入
export LANG=zh_TW.UTF-8
2. ~/.vimrc
加入
if has("multi_byte")
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
set fileencodings=utf-8,ucs-bom,big5,latin1
else
echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"
endif
不確定是否有沒有更好的設定方式,不過,我已經滿意了。

1 則留言:

匿名 提到...

To be a good charitable being is to procure a kind of openness to the in the seventh heaven, an gift to trust uncertain things beyond your own manage, that can front you to be shattered in very extreme circumstances as which you were not to blame. That says something very important about the get of the principled passion: that it is based on a trustworthiness in the uncertain and on a willingness to be exposed; it's based on being more like a plant than like a treasure, something fairly fragile, but whose acutely precise handsomeness is inseparable from that fragility.