set nocompatible set tags=~/.tags " display " ---------------------- set number set ruler set cmdheight=2 set laststatus=2 set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P set title set linespace=0 set wildmenu set showcmd "set textwidth=78 "set columns=100 "set lines=150 " syntax color " --------------------- syntax on colorscheme ron highlight LineNr ctermfg=darkgrey " search " ---------------------- set ignorecase set smartcase set wrapscan set hlsearch " edit " --------------------- set autoindent set cindent set showmatch set backspace=indent,eol,start set clipboard=unnamed set guioptions+=a set pastetoggle= " tab " -------------------- set tabstop=4 set expandtab set smarttab set shiftwidth=4 set shiftround set nowrap " keymap " -------------------- set bioskey set timeout set timeoutlen=500 " move inoremap inoremap inoremap inoremap inoremap inoremap " date/time inoremap date =strftime('%Y/%m/%d (%a)') inoremap time =strftime('%H:%M') inoremap w3cd =strftime('%Y-%m-%dT%H:%M:%S+09:00') " text-edit inoremap noremap i " brackets" inoremap {} {} inoremap [] [] inoremap () () inoremap "" "" inoremap '' '' inoremap <> <> inoremap []5 [% %] " search nnoremap n nzz nnoremap N Nzz nnoremap * *zz nnoremap # #zz nnoremap g* g*zz nnoremap g# g#zz " window nnoremap 1 :only nnoremap 2 :sp nnoremap 3 :vsp " buffer nnoremap bb :b# nnoremap bp :bp nnoremap bn :bn nnoremap bd :bd nnoremap ls :ls:b " omni "function InsertTabWrapper() " if pumvisible() " return "\" " endif " let col = col('.') - 1 " if !col || getline('.')[col - 1] !~ '\k\|<\|/' " return "\" " elseif exists('&omnifunc') && &omnifunc == '' " return "\" " else " return "\\" " endif "endfunction "inoremap =InsertTabWrapper() " backup " -------------------- set backup set backupdir=~/vim_backup set swapfile set directory=~/vim_swap " " ------------------------------------------------ " encoding " > http://www.kawaz.jp/pukiwiki/?vim " ------------------------------------------------ " set encoding=euc-jp set fileencodings=iso-2022-jp,sjis,utf8 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 " " ------------------------------------------------ " encoding " > http://www.kawaz.jp/pukiwiki/?vim " ------------------------------------------------ " set encoding=euc-jp set fileencodings=iso-2022-jp,sjis,utf8 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 " " http://nanasi.jp/articles/vim/bufonly_vim.html#id4 " " ----------------------------------------------------------------------- " BufOnly.vim - Delete all the buffers except the current/named buffer. " " Copyright November 2003 by Christian J. Robinson " " Distributed under the terms of the Vim license. See ":help license". " " Usage: " " :Bonly / :BOnly / :Bufonly / :BufOnly [buffer] " " Without any arguments the current buffer is kept. With an argument the " buffer name/number supplied is kept. " ----------------------------------------------------------------------- " command! -nargs=? -complete=buffer -bang Bonly \ :call BufOnly('', '') command! -nargs=? -complete=buffer -bang BOnly \ :call BufOnly('', '') command! -nargs=? -complete=buffer -bang Bufonly \ :call BufOnly('', '') command! -nargs=? -complete=buffer -bang BufOnly \ :call BufOnly('', '') function! BufOnly(buffer, bang) if a:buffer == '' " No buffer provided, use the current buffer. let buffer = bufnr('%') elseif (a:buffer + 0) > 0 " A buffer number was provided. let buffer = bufnr(a:buffer + 0) else " A buffer name was provided. let buffer = bufnr(a:buffer) endif if buffer == -1 echohl ErrorMsg echomsg "No matching buffer for" a:buffer echohl None return endif let last_buffer = bufnr('$') let delete_count = 0 let n = 1 while n <= last_buffer if n != buffer && buflisted(n) if a:bang == '' && getbufvar(n, '&modified') echohl ErrorMsg echomsg 'No write since last change for buffer' \ n '(add ! to override)' echohl None else silent exe 'bdel' . a:bang . ' ' . n if ! buflisted(n) let delete_count = delete_count+1 endif endif endif let n = n+1 endwhile if delete_count == 1 echomsg delete_count "buffer deleted" elseif delete_count > 1 echomsg delete_count "buffers deleted" endif endfunction " " --------------------------------------------------------- " closetag.vim " - http://nanasi.jp/articles/vim/closetag_vim.html " - http://www.vim.org/scripts/script.php?script_id=13 " - For insert mode, "Ctrl-_" " --------------------------------------------------------- " :let g:closetag_html_style=1 au Filetype html,xml,xsl,ant source $VIMRUNTIME/macros/closetag.vim " " ---------------------------------------------------------------- " NERD_tree.vim " - http://vim.sourceforge.net/scripts/script.php?script_id=1658 " ---------------------------------------------------------------- " nnoremap ntree :NERDTreeToggle " " ------------------------------------------------------------------- " HTML Key Mappings for Typing Character Codes " " |-------------------------------------------------------------------- " |Keys |Insert |For |Comment " |---------|---------|-----|------------------------------------------- " |\& |& |& |ampersand " |\< |< |< |less-than sign " |\> |> |> |greater-than sign " |\. |· |・ |middle dot (decimal point) " |\? |— |? |em-dash " |\2 |“ |“ |open curved double quote " |\" |” |” |close curved double quote " |\` |‘ |‘ |open curved single quote " |\' |’ |’ |close curved single quote (apostrophe) " |\` |` |` |OS-dependent open single quote " |\' |' |' |OS-dependent close or vertical single quote " |\ |  | |non-breaking space " |--------------------------------------------------------------------- " " > http://www.stripey.com/vim/html.html " " autocmd BufEnter * if &filetype == "html" | call MapHTMLKeys() | endif function! MapHTMLKeys(...) if a:0 == 0 || a:1 != 0 inoremap \\ \ inoremap \& & inoremap \< < inoremap \> > inoremap \. ・ inoremap \- — inoremap \   inoremap \` ‘ inoremap \' ’ inoremap \2 “ inoremap \" ” autocmd! BufLeave * call MapHTMLKeys(0) else iunmap \\ iunmap \& iunmap \< iunmap \> iunmap \- iunmap \ iunmap \` iunmap \' iunmap \2 iunmap \" autocmd! BufLeave * endif " test for mapping/unmapping endfunction " MapHTMLKeys()