設定ファイルさらし

現在、OSX で使ってる .vimrc と .gvimrc 。
(2006/04/11 修正 map 関連とかイロイロ修正)
(2006/10/25 さらに修正)

.vimrc

"==<dir>======================================================================
set backupdir=~/.vim/backup
let &directory=&backupdir

"==<etc>======================================================================
set shortmess+=I
set nu!
set cmdheight=1
set hidden
set history=60

"==<tab>======================================================================
set cindent
set expandtab

"set softtabstop=0
"set tabstop=8
set softtabstop=4
set shiftwidth=4
set tabstop=4

autocmd Syntax perl set softtabstop=4 | set shiftwidth=4 | set tabstop=4
autocmd Syntax ruby set softtabstop=4 | set shiftwidth=4 | set tabstop=4
autocmd Syntax javascript set softtabstop=2 | set shiftwidth=2 | set tabstop=2
autocmd Syntax yaml set softtabstop=2 | set shiftwidth=2 | set tabstop=2
autocmd BufNewFile,BufRead *.tt set softtabstop=2 | set shiftwidth=2 | set tabstop=2
autocmd Syntax html,xhtml set softtabstop=2 | set shiftwidth=2 | set tabstop=2

"==<search>===================================================================
set magic
set ignorecase
set smartcase
set hlsearch
set incsearch

map <F2> :!open -a safari 'http://www.google.co.jp/search?q=<cword>'<CR>
map <F3> :!open -a safari 'http://search.cpan.org/search?query=<cword>&mode=all'<CR>

"==<status line>==============================================================
set laststatus=2
set wildmenu
set ruler
set statusline=%<%f? %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P

"==<color>====================================================================
syntax on
colorscheme desert

set listchars=tab:>_
set list
highlight SpecialKey guifg=#555555

"==<encode>===================================================================
if &encoding !=# 'utf-8'
  set encoding=japan
endif

set fileencoding=japan
if has('iconv')
  let s:enc_euc = 'euc-jp'
  let s:enc_jis = 'iso-2022-jp'

  if 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

  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?|jisx0213?)$'
      set fileencodings+=cp932
      set fileencodings-=euc-jp
      set fileencodings-=euc-jisx0213
      let &encoding = s:enc_euc
    else
      let &fileencodings = &fileencodings .','. s:enc_euc
    endif
  endif

  unlet s:enc_euc
  unlet s:enc_jis
endif

autocmd FileType cvs :set fileencoding=euc-jp
autocmd FileType svn :set fileencoding=utf-8

"==<dictionary>===============================================================
autocmd Syntax perl set dictionary=~/.vim/dict/perl.dict | set iskeyword+=:
set complete+=k

"==<head comment>=============================================================
iab papp <ESC>:r ~/.vim/templates/perl_application.pl<CR>
iab ppkg <ESC>:r ~/.vim/templates/perl_package.pl<CR>
iab pcls <ESC>:r ~/.vim/templates/perl_class.pl<CR>
iab psub <ESC>:r ~/.vim/templates/perl_subroutine.pl<CR>

"==<buffer>===================================================================
map <LEFT> :bp!<CR>
map <RIGHT> :bn!<CR>
map <UP> :ls<CR>
map <DOWN> :b<SPACE>

"==<syntax check>=============================================================
autocmd Syntax perl map ,t :w<CR>:!perl -cw %<CR> | set makeprg=perl? -wc? %
autocmd Syntax ruby map ,t :w<CR>:!ruby -cW %<CR> | set makeprg=ruby? -Wc? %
autocmd Syntax javascript map ,t :w<CR>:!~/bin/js_checker.pl %<CR> | set makeprg=?~/bin/js_checker.pl? %
autocmd Syntax html,xhtml map ,t :w<CR>:!open -a safari %<CR> | set makeprg=open? -a? safari? %
autocmd Syntax yaml map ,t :w<CR>:!~/bin/yaml_checker.pl %<CR> | set makeprg=~/bin/yaml_checker.pl? %

autocmd Syntax html,xhtml map ,r :w<CR>:!~/bin/reload_firefox.sh<CR>
autocmd BufNewFile,BufRead *.tt map ,r :w<CR>:!~/bin/reload_firefox.sh<CR>

"==<move>=====================================================================
nnoremap j gj
nnoremap k gk
nnoremap * g*

"==<pair>=====================================================================
set showmatch
set matchpairs+=<:>

inoremap ( ()<ESC>i
inoremap { {}<ESC>i
inoremap [ []<ESC>i
autocmd Syntax html,xhtml,vim inoremap < <lt>><ESC>i
autocmd BufNewFile,BufRead *.tt inoremap < <lt>><ESC>i
autocmd BufNewFile,BufRead *.tt inoremap [ [%%]<ESC>hi

inoremap ) <C-R>=ClosePair(')')<CR>
inoremap } <C-R>=ClosePair('}')<CR>
inoremap ] <C-R>=ClosePair(']')<CR>
autocmd Syntax html,xhtml,vim inoremap > <C-R>=ClosePair('>')<CR>
autocmd BufNewFile,BufRead *.tt inoremap > <C-R>=ClosePair('>')<CR>

function ClosePair(char)
  if getline('.')[col('.') - 1] == a:char
    return "?<RIGHT>"
  else
    return a:char
  endif
endf

autocmd Syntax perl,ruby nmap ( i(<ESC>lx/?><CR>:call AddClosePair( ')' )<CR>:nohlsearch<CR>
autocmd Syntax perl,ruby nmap { i{<ESC>lx/?><CR>:call AddClosePair( '}' )<CR>:nohlsearch<CR>
autocmd Syntax perl,ruby nmap [ i[<ESC>lx/?><CR>:call AddClosePair( ']' )<CR>:nohlsearch<CR>

function AddClosePair(char)
  if getline('.')[col('.') - 1] =~ '?s'
    execute "normal i" . a:char . "?<ESC>"
  else
    execute "normal a" . a:char . "?<ESC>"
  endif
endf

autocmd Syntax perl,ruby vmap ( v`<I<CR><ESC>k0i(<ESC>lx`>o)<CR><ESC>
autocmd Syntax perl,ruby vmap { v`<I<CR><ESC>k0i{<ESC>lx`>o}<CR><ESC>
autocmd Syntax perl,ruby vmap [ v`<I<CR><ESC>k0i[<ESC>lx`>o]<CR><ESC>

autocmd Syntax perl,ruby nmap ' i'<ESC>/?><CR>:call AddClosePair( "'" )<CR>:nohlsearch<CR>
autocmd Syntax perl,ruby nmap " i"<ESC>/?><CR>:call AddClosePair( '"' )<CR>:nohlsearch<CR>

"==<comment out>==============================================================
autocmd Syntax perl,ruby,sh map ,c :s/^/#/<CR>:nohlsearch<CR>
autocmd Syntax vim map ,c :s/^/"/<CR>:nohlsearch<CR>
autocmd Syntax html,xhtml map ,c :s/^?(.*?)$/<!-- ?1 -->/<CR>:nohlsearch<CR>
autocmd BufNewFile,BufRead *.tt map ,c :s/^?(.*?)$/<!-- ?1 -->/<CR>:nohlsearch<CR>
autocmd Syntax perl,ruby vmap ,b v`<I<CR><ESC>k0i=begen<ESC>`>o=end<CR><ESC>
autocmd Syntax html,xhtml vmap ,b v`<I<CR><ESC>k0i<!--<ESC>`>o--><CR><ESC>
autocmd BufNewFile,BufRead *.tt vmap ,b v`<I<CR><ESC>k0i<!--<ESC>`>o--><CR><ESC>

↑「はてなダイヤリー」の問題だと思うが、「¥」が「?」にかわってしまっている・・・。
statusline の二つ目の「?」以外は、全て 「¥」(もしくは「\」)です。

.vim.perl.dict には、perl の補完用キーワードが詰まっている。
SledgeCatalyst 用のキーワードや、よく使う CPAN モジュールのキーワードが満載。

.gvimrc

set lines=40
set columns=87
set cmdheight=1
set guifont=Osaka−等幅:h16

"set nomacatsui

gui
colorscheme desert
highlight SpecialKey guifg=#555555

set transparency=200

let g:miniBufExplMapWindowNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplMapCTabSwitchBuffs=1
let g:miniBufExplModSelTarget=1

gvim を起動する場合、香り屋さんの gvimrc を先に読むので .gvimrc は、中身スカスカ。