『書物の迷宮』予告篇

思い出したように本を読み、本の読み方を思い出す

Vimの設定関連メモ

.gvimrcとか.vimrcとかのメモ。そういえば、Windowsだと最近はどんなテキストエディタが使われてるんだろう?
TeraPadとか秀丸かな。そういえば、サクラエディタ何て名前も最近聞いた覚えが……。

Vimのインストール

.vimrc

syntax on
set ai
set backspace=indent,eol,start
set nobackup
hi Pmenu ctermbg=8
hi PmenuSel ctermbg=12
hi PmenuSbar ctermbg=0
setlocal omnifunc=syntaxcomplete#Complete
set background=light
:gui
:colorscheme delek

hi Pmenu ctermbg=8
hi PmenuSel ctermbg=12
hi PmenuSbar ctermbg=0

set enc=utf-8 
set fenc=utf-8
set fencs=utf-8,euc-jp,iso-2022-jp,cp932
set ffs=unix

set filetype=on
set shiftwidth=4
set tabstop=4
set smartindent
autocmd FileType c,cpp,perl set cindent
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab
autocmd FileType yaml set expandtab ts=2 sw=2 enc=utf-8 fenc=utf-8

" 文字コードの自動認識
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
" UTF-8の□や○でカーソル位置がずれないようにする
if exists("&ambiwidth")
  set ambiwidth=double
endif
" 改行コードの自動認識
set fileformats=unix,dos,mac

" TabでOmni補完を起動
function InsertTabWrapper()
    if pumvisible()
        return "?<c-n>"
    endif
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '?k?|<?|/'
        return "?<tab>"
    elseif exists('&omnifunc') && &omnifunc == ''
        return "?<c-n>"
    else
        return "?<c-x>?<c-o>"
    endif
endfunction
 
inoremap <tab> <c-r>=InsertTabWrapper()<cr>

.gvimrc

if has('kaoriya')
    "set iminsert=0 imsearch=0
    set iminsert=1 imsearch=0
endif

set guifont=Osaka-Mono:h14
set background=light
set nomacatsui
set termencoding=japan

if has('migemo')
    set migemo
    set migemodict=/usr/local/share/migemo/utf-8/migemo-dict
endif

set nomacatsui
set enc=utf-8 
set fenc=utf-8
set fencs=utf-8,euc-jp,iso-2022-jp,cp932
set ffs=unix
set guioptions=a
set ai
syntax on
set nu
set binary noeol