Created
June 2, 2014 13:19
-
-
Save t11a/bf13fa553a7e37ae75c0 to your computer and use it in GitHub Desktop.
vimrc sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"============================================================================= | |
" vimrc: vimrcはシステム管理者が必要最小限の設定をしておくものであり、 | |
" 個人用の設定は_vimrc(.vimrc)で行う。 | |
" 従ってvimrcは基本的に変更しない。 | |
" 本設定ファイルでは主に文字コードの自動認識のみ行っている。 | |
"============================================================================= | |
set nocompatible | |
"---------------------------------------- | |
"文字コードの自動認識 | |
"---------------------------------------- | |
let &termencoding = &encoding | |
set encoding=utf-8 | |
"Windowsでコンソール版の場合 cp932に設定する | |
if !has('gui') | |
if has('win95') || has('win16') || has('win32') || has('win64') | |
set fileencodings=ucs-bom | |
set encoding=cp932 | |
endif | |
endif | |
" 文字コードの自動認識 | |
if &encoding !=# 'utf-8' | |
set encoding=japan | |
set fileencoding=japan | |
endif | |
if has('iconv') | |
let s:enc_euc = 'euc-jp' | |
let s:enc_jis = 'iso-2022-jp' | |
" iconvがeucJP-msに対応しているかをチェック | |
if iconv("\x87\x64\x87\x6a", 'cp932', 'eucjp-ms') ==# "\xad\xc5\xad\xcb" | |
let s:enc_euc = 'eucjp-ms' | |
let s:enc_jis = 'iso-2022-jp-3' | |
" iconvがJISX0213に対応しているかをチェック | |
elseif iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb" | |
let s:enc_euc = 'euc-jisx0213' | |
let s:enc_jis = 'iso-2022-jp-3' | |
endif | |
" fileencodingsを構築 | |
if &encoding ==# 'utf-8' | |
let s:fileencodings_default = &fileencodings | |
let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932' | |
let &fileencodings = &fileencodings .','. s:fileencodings_default | |
unlet s:fileencodings_default | |
else | |
let &fileencodings = &fileencodings .','. s:enc_jis | |
set fileencodings+=utf-8,ucs-2le,ucs-2 | |
if &encoding =~# '^\(euc-jp\|euc-jisx0213\|eucjp-ms\)$' | |
set fileencodings+=cp932 | |
set fileencodings-=euc-jp | |
set fileencodings-=euc-jisx0213 | |
set fileencodings-=eucjp-ms | |
let &encoding = s:enc_euc | |
let &fileencoding = s:enc_euc | |
else | |
let &fileencodings = &fileencodings .','. s:enc_euc | |
endif | |
endif | |
" 定数を処分 | |
unlet s:enc_euc | |
unlet s:enc_jis | |
endif | |
"let &fileencodings = substitute(&fileencodings, 'utf-8', '_utf-8', 'g') | |
"let &fileencodings = substitute(&fileencodings, 'cp932', 'utf-8', 'g') | |
"let &fileencodings = substitute(&fileencodings, '_utf-8', 'cp932', 'g') | |
" 日本語を含まない場合は fileencoding に encoding を使うようにする | |
if has('autocmd') | |
function! AU_ReCheck_FENC() | |
if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0 | |
let &fileencoding=&encoding | |
if has('win95') || has('win16') || has('win32') || has('win64') | |
let &fileencoding='cp932' | |
endif | |
endif | |
endfunction | |
autocmd BufReadPost * call AU_ReCheck_FENC() | |
endif | |
" 改行コードの自動認識 | |
set fileformats=unix,dos,mac | |
" □や○の文字があってもカーソル位置がずれないようにする。 | |
if exists('&ambiwidth') | |
set ambiwidth=double | |
endif | |
"---------------------------------------- | |
"メッセージの日本語化 | |
"---------------------------------------- | |
if has('unix')&&has('gui_running') | |
let $LANG='ja' | |
endif | |
"---------------------------------------- | |
"オプション設定 | |
"---------------------------------------- | |
set hidden | |
set number | |
set title | |
set cmdheight=2 | |
set laststatus=2 | |
set showcmd | |
set ruler | |
set display=lastline | |
set shellslash | |
set ignorecase | |
set smartcase | |
set incsearch | |
set wildmenu | |
set whichwrap=b,s,[,],<,> | |
set backspace=indent,eol,start | |
if &t_Co > 2 || has("gui_running") | |
syntax on | |
set hlsearch | |
endif | |
set tabstop=2 | |
set expandtab | |
"set autoindent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment