Vim初心者がvimrcを晒してみる

Vimを使い始めてそこそこたつけれど本格的に使い始めてからは数ヶ月
コピペだらけながらvimrc,gvimrcを書いたので晒す

vimrc

set nocompatible
set nobackup
set noswapfile
set hidden
set number
set bs=indent,eol,start
set showmatch
syntax on
filetype plugin indent on
set encoding=utf-8
set fileformat=unix
set fileformats=unix,dos,mac
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P

" Indent, Tab
set autoindent
set smartindent
set expandtab
set tabstop=4
set shiftwidth=4
autocmd FileType ruby setlocal tabstop=2 shiftwidth=2
"autocmd FileType python set local tabstop=4 shiftwidth=4

" Search
set incsearch
set noignorecase
set smartcase
set hlsearch
set wrapscan

" Keymap
nnoremap j gj
nnoremap k gk

" enc/fenc
command! -bang -nargs=? Utf8Edit edit<bang> ++enc=utf-8 <args>
command! -bang -nargs=? EucjpEdit edit<bang> ++enc=euc-jp <args>
command! -bang -nargs=? SjisEdit edit<bang> ++enc=sjis <args>
command! -nargs=0 Utf8Set setlocal fenc=utf-8
command! -nargs=0 EucjpSet setlocal fenc=euc-jp
command! -nargs=0 SjisSet setlocal fenc=sjis
nnoremap <Leader>eu :Utf8Edit<CR>
nnoremap <Leader>ee :EucjpEdit<CR>
nnoremap <Leader>es :SjisEdit<CR>
nnoremap <Leader>su :Utf8Set<CR>
nnoremap <Leader>se :EucjpSet<CR>
nnoremap <Leader>ss :SjisSet<CR>

" http://www.kawaz.jp/pukiwiki/?vim
" 文字コードの自動認識
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
" 日本語を含まない場合は fileencoding に encoding を使うようにする
if has('autocmd')
  function! AU_ReCheck_FENC()
    if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0
      let &fileencoding=&encoding
    endif
  endfunction
  autocmd BufReadPost * call AU_ReCheck_FENC()
endif
" 改行コードの自動認識
set fileformats=unix,dos,mac
" □とか○の文字があってもカーソル位置がずれないようにする
if exists('&ambiwidth')
  set ambiwidth=double
endif


"" Plugins
" mru.vim
noremap <Space>h :MRU<CR>
let MRU_Max_Entries=50

" qbuf.vim
let g:qb_hotkey = "<Space><Space>"

" fuzzyfinder.vim
noremap <Space>b :FuzzyFinderBuffer<CR>
noremap <Space>d :FuzzyFinderDir<CR>
noremap <Space>f :FuzzyFinderFile<CR>
noremap <Space>m :FuzzyFinderMruFile<CR>

gvimrc

colorscheme wombat
"colorscheme desert
"colorscheme baycomb

if has("win32")
    au GUIEnter * simalt ~x
else
    au GUIEnter * set lines=50
    au GUIEnter * set columns=150
endif

augroup InsertHook
autocmd!
autocmd InsertEnter * highlight StatusLine guifg=#ccdc90 guibg=#2E4340
autocmd InsertLeave * highlight StatusLine guifg=#2E4340 guibg=#ccdc90
augroup END

set guioptions-=r

if has('win32')
  set guifont=MS_Gothic:h10
endif

"全角スペースを視覚化
highlight ZenkakuSpace cterm=reverse ctermfg=DarkCyan guibg=LightBlue
autocmd BufRead,BufNewFile * match ZenkakuSpace / /

[asin:4774143960:detail]