| 94 | | if has('iconv') |
| 95 | | let s:enc_euc = 'euc-jp' |
| 96 | | let s:enc_jis = 'iso-2022-jp' |
| 97 | | " iconvがeucJP-msに対応しているかをチェック |
| 98 | | if iconv("¥x87¥x64¥x87¥x6a", 'cp932', 'eucjp-ms') ==# "¥xad¥xc5¥xad¥xcb" |
| 99 | | let s:enc_euc = 'eucjp-ms' |
| 100 | | let s:enc_jis = 'iso-2022-jp-3' |
| 101 | | " iconvがJISX0213に対応しているかをチェック |
| 102 | | elseif iconv("¥x87¥x64¥x87¥x6a", 'cp932', 'euc-jisx0213') ==# "¥xad¥xc5¥xad¥xcb" |
| 103 | | let s:enc_euc = 'euc-jisx0213' |
| 104 | | let s:enc_jis = 'iso-2022-jp-3' |
| 105 | | endif |
| 106 | | " fileencodingsを構築 |
| 107 | | if &encoding ==# 'utf-8' |
| 108 | | let s:fileencodings_default = &fileencodings |
| 109 | | let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932' |
| 110 | | let &fileencodings = &fileencodings .','. s:fileencodings_default |
| 111 | | unlet s:fileencodings_default |
| 112 | | else |
| 113 | | let &fileencodings = &fileencodings .','. s:enc_jis |
| 114 | | set fileencodings+=utf-8,ucs-2le,ucs-2 |
| 115 | | if &encoding =~# '^¥(euc-jp¥|euc-jisx0213¥|eucjp-ms¥)$' |
| 116 | | set fileencodings+=cp932 |
| 117 | | set fileencodings-=euc-jp |
| 118 | | set fileencodings-=euc-jisx0213 |
| 119 | | set fileencodings-=eucjp-ms |
| 120 | | let &encoding = s:enc_euc |
| 121 | | let &fileencoding = s:enc_euc |
| 122 | | else |
| 123 | | let &fileencodings = &fileencodings .','. s:enc_euc |
| 124 | | endif |
| 125 | | endif |
| 126 | | " 定数を処分 |
| 127 | | unlet s:enc_euc |
| 128 | | unlet s:enc_jis |
| 129 | | endif |
| 130 | | " 日本語を含まない場合は fileencoding に encoding を使うようにする |
| 131 | | if has('autocmd') |
| 132 | | function! AU_ReCheck_FENC() |
| 133 | | if &fileencoding =~# 'iso-2022-jp' && search("[^¥x01-¥x7e]", 'n') == 0 |
| 134 | | let &fileencoding=&encoding |
| 135 | | endif |
| 136 | | endfunction |
| 137 | | autocmd BufReadPost * call AU_ReCheck_FENC() |
| 138 | | endif |
| 139 | | " 改行コードの自動認識 |
| 140 | | set fileformats=unix,dos,mac |
| 141 | | " □とか○の文字があってもカーソル位置がずれないようにする |
| 142 | | if exists('&ambiwidth') |
| 143 | | set ambiwidth=double |
| 144 | | endif |
| 145 | | |