" " 基本的な設定 " set nocompatible " Use Vim defaults instead of 100% vi compatibility syntax on set runtimepath+=~/.vim set wildmode=list:longest " コマンドライン補間をシェルっぽく set hidden " バッファが編集中でもその他のファイルを開けるように set autoread " 外部のエディタで編集中のファイルが変更されたら自動で読み直す set backspace=indent,eol,start " allow backspacing over everything in insert mode set textwidth=0 " Don't wrap words by default set nobackup " Don't keep a backup file set viminfo='50,<1000,s100,\"50 " read/write a .viminfo file, don't store more than set history=100 " keep 50 lines of command line history set ruler " show the cursor position all the time set expandtab set tabstop=4 set softtabstop=4 set shiftwidth=4 set modelines=0 set smartindent "インデントはスマートインデント set ignorecase "検索文字列が小文字の場合は大文字小文字を区別なく検索する set smartcase "検索文字列に大文字が含まれている場合は区別して検索する set wrapscan "検索時に最後まで行ったら最初に戻る " set incsearch set noincsearch "検索文字列入力時に順次対象文字列にヒットさせない set nolist set showcmd "入力中のコマンドをステータスに表示する set showmatch "括弧入力時の対応する括弧を表示 set nohlsearch "検索結果文字列のハイライトを有効にしない set laststatus=2 "ステータスラインを常に表示 set completeopt=menu,preview,longest,menuone " Suffixes that get lower priority when doing tab completion for filenames. " These are files we are not likely to want to edit or read. set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc " " 色設定 " colorscheme inkpot_bak " 16色 set t_Co=256 set t_Sf=[3%dm set t_Sb=[4%dm " 補完候補の色づけ hi Pmenu ctermbg=8 hi PmenuSel ctermbg=12 hi PmenuSbar ctermbg=0 " マウス "if has('mac') " set mouse=a " set ttymouse=xterm2 "endif " autocmd FileType perl set dictionary=~/.vim/dict/perl_function.dict " autocmd FileType actionscript set dictionary=~/.vim/dict/actionscript_function.dict setlocal omnifunc=syntaxcomplete#Complete " 辞書ファイルからの単語補間 set complete+=k " autocmd FileType eruby setlocal omnifunc=htmlcomplete#CompleteTags " autocmd FileType tt2html setlocal omnifunc=htmlcomplete#CompleteTags " 検索後、真ん中にフォーカスをあわせる nmap n nzz nmap N Nzz nmap * *zz nmap # #zz nmap g* g*zz nmap g# g#zz " Don't use Ex mode, use Q for formatting map Q gq " Make p in Visual mode replace the selected text with the "" register. vnoremap p :let current_reg = @"gvdi=current_reg " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, " so that you can undo CTRL-U after inserting a line break. inoremap u " set tags set tags=tags; " tags key map map nmap g " command mode 時 tcsh風のキーバインドに cmap cmap cmap cmap cmap b cmap f "表示行単位で行移動する nmap j gj nmap k gk vmap j gj vmap k gk "フレームサイズを怠惰に変更する map + map - ",e で実行 nmap ,e :execute '!' &ft ' %' " reload safari map ,t :w:!sh ~/.vim/bin/reload_safari.sh " " enable file type indent and plugin " if has("autocmd") filetype plugin on filetype indent on " これらのfiletypeではインデントを無効に " autocmd FileType php :set indentexpr= autocmd FileType html :set indentexpr= autocmd FileType erb :set indentexpr= autocmd FileType xhtml :set indentexpr= autocmd FileType rhtml :set indentexpr= endif " "ステータスラインに文字コードと改行文字を表示する " if winwidth(0) >= 120 set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %F%=[%{GetB()}]\ %l,%c%V%8P else set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %f%=[%{GetB()}]\ %l,%c%V%8P endif " " 文字コード関連 " from ずんWiki http://www.kawaz.jp/pukiwiki/?vim#content_1_7 " 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' " iconvがJISX0213に対応しているかをチェック 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 " 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\|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 " svnの時は文字コードをutf-8に設定 autocmd FileType svn :set fileencoding=utf-8 " " minibufexpl.vim " let g:miniBufExplMapWindowNavVim=1 let g:miniBufExplSplitBelow=0 let g:miniBufExplMapWindowNavArrows=1 let g:miniBufExplMapCTabSwitchBufs=1 let g:miniBufExplModSelTarget=1 let g:miniBufExplSplitToEdge=1 " let g:miniBufExplModSelTarget = 1 let mapleader = "" " nnoremap f :MBEbn " nnoremap :MBEbn nnoremap n :MBEbn nnoremap :MBEbn nnoremap p :MBEbp nnoremap :MBEbp nnoremap c :new nnoremap :new nnoremap k :bd nnoremap :bd nnoremap s :IncBufSwitch nnoremap :IncBufSwitch nnoremap :wincmd w nnoremap Q :only nnoremap w :ls nnoremap :ls nnoremap a :e # nnoremap :e # nnoremap " :BufExp nnoremap 1 :e #1 nnoremap 2 :e #2 nnoremap 3 :e #3 nnoremap 4 :e #4 nnoremap 5 :e #5 nnoremap 6 :e #6 nnoremap 7 :e #7 nnoremap 8 :e #8 nnoremap 9 :e #9 " FuzzyFinder.vim nnoremap b :FufBuffer! nnoremap :FufBuffer! nnoremap f :FufFile! nnoremap :FufFile! " " YankRing.vim " noremap ,y :YRShow " " surround.vim " autocmd FileType php let b:surround_45 = "" " map to - " Taglist.vim nnoremap l :Tlist nnoremap :Tlist nnoremap o :TlistClose nnoremap :TlistClose "vcscommand.vim nmap ,ca :VCSAdd nmap ,cn :VCSAnnotate nmap ,cc :VCSCommit nmap ,cD :VCSDelete nmap ,cd :VCSDiff nmap ,cg :VCSGotoOriginal nmap ,cG :VCSGotoOriginal! nmap ,ci :VCSInfo nmap ,cl :VCSLog nmap ,cL :VCSLock nmap ,cr :VCSReview nmap ,cs :VCSStatus nmap ,cu :VCSUpdate nmap ,cU :VCSUnlock nmap ,cv :VCSVimDiff " commentout setting vmap ,# :s/^/#/:nohlsearch vmap ,/ :s/^/\/\//:nohlsearch vmap ,> :s/^/> /:nohlsearch vmap ," :s/^/\"/:nohlsearch vmap ,% :s/^/%/:nohlsearch vmap ,! :s/^/!/:nohlsearch vmap ,; :s/^/;/:nohlsearch vmap ,- :s/^/--/:nohlsearch " " functions " " html escape function :function HtmlEscape() silent s/&/\&amp;/eg silent s//\>/eg :endfunction :function HtmlUnEscape() silent s/<//eg silent s/&/\&/eg :endfunction function! GetB() let c = matchstr(getline('.'), '.', col('.') - 1) let c = iconv(c, &enc, &fenc) return String2Hex(c) endfunction " :help eval-examples " The function Nr2Hex() returns the Hex string of a number. func! Nr2Hex(nr) let n = a:nr let r = "" while n let r = '0123456789ABCDEF'[n % 16] . r let n = n / 16 endwhile return r endfunc " The function String2Hex() converts each character in a string to a two " character Hex string. func! String2Hex(str) let out = '' let ix = 0 while ix < strlen(a:str) let out = out . Nr2Hex(char2nr(a:str[ix])) let ix = ix + 1 endwhile return out endfunc " Only do this part when compiled with support for autocommands. if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " For all text files set 'textwidth' to 78 characters. " autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). " Also don't do it when the mark is in the first line, that is the default " position when opening a file. autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END else set autoindent " always set autoindenting on endif " has("autocmd") " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. " Only define it when not defined already. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis endif