vim+latex用の.vimrc(バックアップ?)

ついでにvim用の設定も残しておく.
文字コードの設定をなんとかしたほうが良い気がする.
いや,確認すべき.
というか,汚いので近日中にコードを書き直すべき.

"set encoding=japan
"set fileencodings=iso-2002-jp,utf-8,euc-jp,cp932 

syntax on
set number
"改行・タブ・スペースの強調,また書く記号の表示文字・色の設定
set list
set listchars=eol:$,tab:->
highlight NonText ctermfg=DarkGrey
highlight SpecialKey ctermfg=DarkGrey
highlight JpSpace ctermfg=DarkGrey cterm=underline
au BufRead,BufNew * match JpSpace / / " スラッシュの間は全角スペース
set mouse=a"マウスでカーソルの移動,選択,ホイールスクロールを可能に

"ステータス行に現在の(Vim が認識している) ファイルエンコーディングと改行コード
" Status line
function! GetEnc()
  return '[' . &fileencoding . ':' . &fileformat . ']'
endfunction

set laststatus=2
set statusline=%y%m%F%=%{GetEnc()}




""ファイルを開いたときに文字コードを自動的に認識するための記述
" 文字コードの自動認識
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
""

filetype plugin on
filetype indent on
set shellslash
set grepprg=grep\ -nH\ $*

let g:tex_flavor='latex' 

" コンパイル時に使用するコマンド
let g:Tex_CompileRule_dvi = 'platex --interaction=nonstopmode $*' 
let g:Tex_BibtexFlavor = 'jbibtex'
let g:Tex_CompileRule_pdf = 'dvipdfmx $*.dvi'

" ファイルのビューワー
"let g:Tex_ViewRule_dvi = 'xdvi'
let g:Tex_ViewRule_dvi = 'dviout'
"let g:Tex_ViewRule_dvi = 'C:\tex\dviout\dviout.exe'
"let g:Tex_ViewRule_pdf = 'evince'

"au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex
au BufNewFile,BufRead *.tex,*.latex,*.sty,*.dtx,*.ltx,*.bbl	setf tex