" vim: set fdm=marker sw=2 sts=2 cms="%s : "============================================================================= "init "----------------------------------------------------------------------------- "Encodings, Formats"{{{ scriptencoding utf8 "このファイルのエンコード if has("win32") se tenc =cp932 "Ref.vimでlynxがデフォルトで使うエンコード endif se encoding=utf8 se fileencodings=utf8,cp932,iso-2022-jp,euc-jp,default,latin "<< BufRead時、'fileencodings'の先頭から'encoding'を試してerrが出なければそれを適用する "改行コードの自動認識(新規作成されるファイルフォーマットをdosにしたい) se fileformats=dos,unix,mac "--- "setglobal fileencoding=cp932 "新規作成されるファイルエンコードをcp932にしたい "}}} "環境変数を作る"{{{ "$HOME がないとき、$VIM/TMPHOME を $HOME にする "{{{ if !exists("$HOME") let $HOME=$VIM. '/TMPHOME' endif "}}} "$VIMFILES "{{{ if has('vim_starting') if isdirectory(expand('$HOME/vimfiles', ':p')) let $VIMFILES = $HOME. '/vimfiles' set runtimepath+=$HOME/vimfiles/neobundle/neobundle.vim call neobundle#rc(expand('$HOME/vimfiles/neobundle')) else let $VIMFILES = $VIM. '/vimfiles' set runtimepath+=$VIM/vimfiles/neobundle/neobundle.vim call neobundle#rc(expand('$VIM/vimfiles/neobundle')) endif endif "}}} "}}} "----------------------------------------------------------------------------- "Plugins init setting "sow.vim "map ,s (sow_start) let g:sow_dc = '~/.sow_dc/.old' "neobundle.vim"{{{ filetype off "$VIMFILES参照; neobundle#rc()の実行 "-------------------------------------- "拡張インターフェイス NeoBundle 'Shougo/unite.vim' NeoBundleLazy 'kien/ctrlp.vim' NeoBundle 'Shougo/vimshell' NeoBundle 'Shougo/vimfiler', {'depends': 'Shougo/unite.vim'} NeoBundle 'tsukkee/lingr-vim' NeoBundle 'tpope/vim-fugitive' NeoBundle 'pocket7878/presen-vim', {'depends': 'pocket7878/curses-vim'} NeoBundle 'thinca/vim-showtime' NeoBundle 'thinca/vim-ref' NeoBundle 'thinca/vim-quickrun' "NeoBundle 'mattn/gist-vim' "exe "NeoBundle 'mrtazz/simplenote.vim'" | "オンラインノートsimplenoteを使う "exe "NeoBundle 'gregsexton/gitv'" | "vim版Gitk() "exe "NeoBundle 'tomtom/ttoc_vim', {'depends': 'tomtom/tlib_vim'}" | "アウトライナ "exe "NeoBundle 'kien/ctrlp.vim'" | "カレントファイルにアクセスする "NeoBundle 'vim-scripts/vimwiki' "NeoBundle 'https://github.com/fuenor/qfixhowm.git' "-------------------------------------- "ライブラリ NeoBundle 'Shougo/vimproc' NeoBundle 'tomtom/tlib_vim' exe 'NeoBundle "vim-jp/vital.vim"' | "最近なぜかNeoBundleからアップデートできない exe "NeoBundle 'thinca/vim-openbuf'" | "unite-vim_hacksがこれに依存 "exe "NeoBundle 'mattn/wwwrenderer-vim'" | "webpage(only text)を返す "exe "NeoBundle 'mattn/webapi-vim'" | " NeoBundle 'pocket7878/curses-vim' "-------------------------------------- "環境 "exe "NeoBundle 'kana/vim-tabpagecd'" | "TabPage毎にcrrdirを持てるようにする NeoBundle 'tyru/open-browser.vim' NeoBundle 'Shougo/neobundle.vim' NeoBundle 'tpope/vim-pathogen' NeoBundle 'kana/vim-submode' "exe "NeoBundle 'thinca/vim-localrc'" | "特定dir以下に.lvimrcを置くとdir以下のfileだけで設定反映 NeoBundle 'Rykka/lastbuf.vim' NeoBundle 'LeafCage/revolver.vim' "-------------------------------------- "拡張文章 "NeoBundle 'vim-jp/vimdoc-ja' exe "NeoBundle 'https://github.com/ujihisa/mdv.git'" | "VimHacksで使われている拡張Markdown NeoBundleLazy 'motemen/hatena-vim' "-------------------------------------- "入力・移動 NeoBundle 'Shougo/neocomplcache' NeoBundle 'Shougo/neocomplcache-snippets-complete', {'depends': 'Shougo/neocomplcache'} NeoBundle 'kana/vim-textobj-user' exe "NeoBundle 'h1mesuke/textobj-wiw'" | "カーソルドのwordを選択する/ CamelCaseMotionの働きも? NeoBundle 'kana/vim-textobj-indent' exe "NeoBundle 'thinca/vim-textobj-plugins'" | "中身はtextobj-between NeoBundle 'anyakichi/vim-textobj-xbrackets' NeoBundle 'anyakichi/vim-surround' NeoBundle 'scrooloose/nerdcommenter' "NeoBundle 'tomtom/tcomment_vim' NeoBundle 'bkad/CamelCaseMotion' "NeoBundle 'kana/vim-smartword' "NeoBundle 'kana/vim-smartchr' exe "NeoBundle 'thinca/vim-poslist'" | "Bible 3-13 exe "NeoBundle 'thinca/vim-visualstar'" | " *検索 #B3-14 exe "NeoBundleLazy 'https://github.com/vim-scripts/DrawIt.git'" | "図を描写する #Bible5-4 exe "NeoBundleLazy 'https://github.com/vim-scripts/Align.git'" | "高機能なテキストファイル整形ツール #Bible5-11 NeoBundleLazy 'https://github.com/tpope/vim-speeddating.git' "-------------------------------------- "コマンドライン exe "NeoBundle 'thinca/vim-ambicmd'" | "コマンド名省入力 ex)NeoBundleUpdate > NBU exe "NeoBundle 'tyru/vim-altercmd'" | "コマンドのエイリアスを作る tyru版あり #B9-6 "-------------------------------------- "情報表示 exe "NeoBundle 'tacroe/unite-mark'" | "マーク一覧を表示 exe "NeoBundle 'tsukkee/unite-tag'" | exe "NeoBundle 'tsukkee/unite-help'" | NeoBundle 'tyru/current-func-info.vim' exe "NeoBundle 'https://github.com/ujihisa/neco-look.git'" | "要look.exe NeoBundle 'h1mesuke/unite-outline' "NeoBundle 'Shougo/echodoc' "NeoBundleLazy 'choplin/unite-vim_hacks', {'depends', 'thinca/vim-openbuf'} NeoBundle 'rbtnn/sign.vim' "-------------------------------------- "GUI操作 exe "NeoBundle 't9md/vim-quickhl'" | "複数の検索ハイライト NeoBundle 'tyru/winmove.vim' NeoBundle 'thinca/vim-fontzoom' "exe "NeoBundle 'ujihisa/unite-font'" | "動かない exe "NeoBundle 'ujihisa/unite-colorscheme'" | NeoBundle 'pasela/unite-webcolorname' filetype plugin indent on "ファイル判定をonにする "}}} "pathogen.vim"{{{ filetype off "一度ファイル判定をoffにしないとftdetectをロードしてくれないので。 call pathogen#runtime_append_all_bundles() call pathogen#helptags() filetype plugin indent on "ファイル判定をonにする "}}} call altercmd#load() "altercmdをこのvimrc内で有効にする "----------------------------------------------------------------------------- "マウスを有効にする"{{{ if has('mouse') se mouse=a endif "}}} "----------------------------------------------------------------------------- "Backup"{{{ "backupfile "{{{ ":h backup-table se nobk nowb "NOTE: 'nobk'で'wb'だと書き込みに失敗したときのみbackupfileが残される se bex=.bcu se bdir=/tmp/auBcu/,. if !isdirectory(&bdir) call mkdir(&bdir, "p") endif "}}} "swapfile "{{{ se swf se dir=~/vimswap/,. if !isdirectory(&dir) call mkdir(&dir, "p") endif "}}} "undofile"{{{ if version >= 703 se undofile let &udir = &bdir endif "}}} "viminfofile "{{{ se vi= se vi+='20 "marks se vi+=<50 "register limit (line) se vi+=s10 "register limit (Kbyte) se vi+=% "buffers list se vi+=h "viminfoを読み込むとき 'hlsearch' を無効にする se vi+=ra:,rb: "removable mediaの指定 (mark履歴対象外にする) "se vi+=n$VIM/.viminfo "viminfo file name (作成する場所) se vi+=n~/.viminfo "viminfo file name (作成する場所) "}}} "}}} "============================================================================= "編集設定 "----------------------------------------------------------------------------- "Indent, 自動整形"{{{ se et ts=2 sts=2 sw=2 ai "'ts' 見かけ "'sts' の挿入やの使用等の編集操作 "'sw' 'ci'や'ai'や>>で挿入されるindent "行継続の際、挿入されるindent量 :h ft-vim-indent let g:vim_indent_cont = &sw se cin cino& cino+=:0 "< 'cino' については実際使うときになって考え直す必要性 :h cinoptions-values se smartindent "auto-format se formatoptions= "se fo +=t "'textwidth' を使ってテキストを自動折返しする se fo +=q ""gq" でコメントを整形する。 se fo +=n "番号付きリスト等を認識して折り返す se fo +=M "マルチバイト文字連結時空白を挿入しない se fo +=m "マルチバイト文字でも整形を有効にする "改行時にコメントしない(上手く動いていない(上書きされてる)) "aug vimrc_fo " au! " au FileType * setlocal fo-=ro "aug END "}}} "----------------------------------------------------------------------------- "検索"{{{ se ws hls is se tags=./tags,tags,../tags "tagsファイルの読み込み先 "grepコマンドで使うプログラムを何にするか "set grepprg=internal " vimgrep をデフォルトのgrepとする場合internal "set grepprg=D:/bnr/cmd/cygwingrep/bin/cyggrep.exe\ -nH ""-n;:行番表示-H;:ファイル名表示 set grepprg=jvgrep ""-n;:行番表示-H;:ファイル名表示 "set grepprg=cyggrep.exe\ -nH "}}} "----------------------------------------------------------------------------- "書き込み・終了"{{{ ":w等でどこにファイルを保存するか set browsedir=buffer " 他で書き換えられたら自動で読み直す set autoread " バッファへの変更を保存しないで終了するとき、確認する set confirm "}}} "----------------------------------------------------------------------------- "Window se lines=40 co=100 "se scrolloff=2 se hh=0 pvh=0 ea se wmw=0 se ch=2 "コマンドラインの高さ " Window位置の保存と復帰 "{{{ if has('gui_running') if has('unix') let s:infofile = '~/.vim/.vimpos' else let s:infofile = '$VIM/.vimpos' endif augroup WinPosSizeSaver au! augroup END exe 'au WinPosSizeSaver VimLeave * call s:WinPosSizeSave("'.s:infofile.'")' if filereadable(expand(s:infofile)) execute 'source '.s:infofile endif unlet s:infofile endif function! s:WinPosSizeSave(filename)"{{{ let saved_reg = @a redir @a winpos redir END let px = substitute(@a, '.*X \(\d\+\).*', '\1', '') + 0 let py = substitute(@a, '.*Y \(\d\+\).*', '\1', '') + 0 exe 'redir! >'.a:filename if px > 0 && py > 0 echo 'winpos '.px.' '.py endif echo 'set lines='.&lines.' columns='.&columns redir END let @a = saved_reg endfunction "}}} "}}} "----------------------------------------------------------------------------- "カーソルの挙動"{{{ "実際に文字がないところにカーソルを置けるようにする se ve =block,onemore "カーソル左右の動き se ww= se ww+=b " se ww+=s " se ww+=h se ww+=l se ww+=< " (nv) se ww+=> " (nv) se ww+=[ " (i Replace) se ww+=] " (i Replace) "等をindentやeolを越えて有効にする se bs=indent,eol,start "}}} " ファイルを開いたら前回のカーソル位置へ移動 TODO:mkviewに置き換える aug vimrc_ex au! au BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line('$') | \ exe "normal! g`\"" | \ endif aug END "----------------------------------------------------------------------------- "その他挙動 "AltKeyでmenuにアクセスするか se wak =no "keybind timeout se to tm=5000 ttm=100 "に影響 se nf=hex se history=50 "コマンド履歴保存数 se clipboard= se modeline se wrap " 行を折り返す se sm mat=1 "括弧の対応表示時間 "============================================================================= "特殊UI "補完を有効にする set completeopt=menu,menuone,longest,preview "折り畳み se fdm=marker cms=%s fdc=5 fdt=FoldCCtext() "----------------------------------------------------------------------------- "Statusline se stl =%!Gs_StatusLine() "au WinEnter * setl stl=%!Gs_StatusLine() let g:shujuu_top = 1 let g:shujuu_bottom = 5 function! Gs_StatusLine() "{{{ let crrbuf_head = '%{empty(bufname("%")) ? "" : expand(''%:p:h'')."/"}' let crrbuf_tail = '%9*%t %0*' "< tail の highlight を変えている :h hl-User1 let crrbuf_path = crrbuf_head .crrbuf_tail let fenc8ff = '[%{&fenc}/%{&ff[:0]}]' let info = '' if exists('*cfi#format') let info .= '%8*%{cfi#format("%.43s()" ,"")}%0*' endif let funclnum = s:__gi_funclnum() let info .= '%8*%{exists("b:vimfiler.current_dir")?b:vimfiler.current_dir :""}%0*' let win_shujuukankei = ['天', '主', '副', '平', '僕', '隷'] return \ '%3(%{repeat(",", winnr()).","}'. '%{'.string(win_shujuukankei).'[exists("b:shujuu_overtaker")?0:w:shujuu]}%*%)'. \ '%3n-'. '%.40('. crrbuf_path. '%)'. \ '%m%R%H%W%y %('. fenc8ff .'%) '. \ info . funclnum. '%='. \ '%14(~%L~ %l,%v%)%< %P' "\ '['. '%{winnr()}'. '%7*%{'.string(win_shujuukankei).'[w:shujuu]}%*'. ']'. "\ '%#%{ShujuuColor()}#'. '%{g:win_shujuukankei[w:shujuu]}%*'. '%13([%L] %l,%v%)%< %P' "\ '%#ShujuuMaster#'. '%{g:win_shujuukankei[w:shujuu]}%*'. '%13([%L] %l,%v%)%< %P' endfunction "}}} "関数定義始まりから見た行数を返す > function! s:__gi_funclnum() "{{{ let funcdef = search('^\s*\', 'bcnW', search('^\s*\', 'bcnW')) if funcdef > 0 return ' '.(line('.') - funcdef).' ' else return '' endif endfunction "}}} "挿入モード時、ステータスラインのカラー変更 let g:hi_insert = 'hi StatusLine guifg=black guibg=darkyellow gui=bold ctermfg=blue ctermbg=yellow cterm=bold' if has('syntax') syntax on augroup InsertHook au! au InsertEnter * call s:Cng_stlColor('Enter') au InsertLeave * call s:Cng_stlColor('Leave') augroup END endif "i_CTRL-cでstatusLineの色が変更されない問題を修正 inoremap :call Cng_stlcolor('Leave') let s:slhlcmd = '' function! s:Cng_stlColor(mode) "{{{ if a:mode == 'Enter' silent! let s:slhlcmd = 'highlight ' . s:__Gs_hi('StatusLine') silent exec g:hi_insert else highlight clear StatusLine silent exec s:slhlcmd endif endfunction "}}} "----------------------------------------------------------------------------- "TabLine se stal=2 "常に tabline を表示 se tal=%!Gs_TabLine() let g:TDD_idx = 0 noremap [C-k]td :let g:TDD_idx = g:TDD_idx>=3 ?0 :g:TDD_idx+1 function! Gs_TabLine() "{{{ let one2tabpEnd = range(1, tabpagenr('$')) let titles = map(one2tabpEnd, 's:__Gs_Tabpage_label(v:val)') let sep = ' ' "タブ間の区切り let tabpages = join(titles, sep) . sep . '%#TabLineFill#%T' let info = '' " 好きな情報を入れる {{{ "FoldCCnavi if exists('*FoldCCnavi') let info .= '%#TabLineInfo#'.substitute(strtrans(substitute(FoldCCnavi()[-70:],'\s>\s','%#TabLineFill#> %#TabLineInfo#','g')), '<\x\x>','','g') . '%0* ' "let info .= '%#TabLineInfo#%.60('.substitute(FoldCCnavi(),'\s>\s',' >','g').'%)%0* ' endif "Keyswitcherの状態 let info .= g:keyswitcher_modes[g:Keyswitcher_mode_idx]. ' ' "テスト駆動開発の4モードを表示 let info .= ['%#TDD_Think#Tnk%*', '%#TDD_Red#Red%*', '%#TDD_Green#Grn%*', '%#TDD_Refactor#Rfc%*'][g:TDD_idx]. ' ' "gitのブランチ名表示 "let branch_name = s:vcs_branch_name(getcwd()) "let info .= (branch_name != '' ? branch_name : '?') "カレントバッファの総行数 "let info .= '%L' let info .= 'tw%{&tw}' "カレントディレクトリ let info .= '[%.35('.fnamemodify(getcwd(), ":~") . '%)]' "}}} return tabpages . '%=' . info.'' " タブリストを左に、情報を右に表示 endfunction "}}} function! s:__Gs_Tabpage_label(tabpagenr) "{{{ "rol;各タブページのカレントバッファ名+αを表示 let title = gettabvar(a:tabpagenr, 'title') "タブローカル変数 t:title を取得 "<< t:titleを設定していたっけ俺?(されているなら抜けるらしいが) if title !=# '' return title endif " カレントタブページかどうかでハイライトを切り替える let hiTabLable = a:tabpagenr is tabpagenr() ? '%#TabLineSel#' : '%#TabLine#' "let hiWinnum = a:tabpagenr is tabpagenr() ? '%#TabLineSelWinnum#' : '%#TabLineWinnum#' " タブページ内の各ウィンドウにあるバッファのリスト let bufnrs = tabpagebuflist(a:tabpagenr) let winnum = len(bufnrs) "let mod = len(filter(copy(bufnrs), 'getbufvar(v:val, "&modified")')) ? '+' : '' let edBufnr = bufnrs[tabpagewinnr(a:tabpagenr) - 1] "let edBufnr = bufnrs[-1] let fname = fnamemodify(bufname(edBufnr), ':t') let fname = fname is '' ? 'NoTitle' : fname "let tabpagenr = a:tabpagenr > 10 ? 10 : a:tabpagenr-1 "let tabpageNR = ['壱', '弐', '参', '肆', '伍', '陸', '漆', '捌', '玖', '拾', '?'][tabpagenr] return '%'. a:tabpagenr. 'T'. hiTabLable. \ a:tabpagenr. \ repeat(',', winnum). ' '. edBufnr. '-'. fname. \ '%T%#TabLineFill#' "\ edBufnr.'-'. fname. '%T%#TabLineFill#' "\ hiTabLable. '['. a:tabpagenr. '] '. endfunction "}}} "============================================================================= "その他のhighlight "全角スペースを表示 TODO:aug vimrc_colorschemeに加える "{{{ if has('syntax') syntax on aug InvisibleIndicator au! au VimEnter,BufEnter * call ActivateInvisibleIndicator() aug END endif function! ActivateInvisibleIndicator() hi ZenkakuSpace cterm=underline ctermfg=darkgrey gui=underline guifg=darkgrey " 全角スペースを明示的に表示する。 silent! 2match ZenkakuSpace / / endfunction "}}} "窓にカーソルの痕跡を残す aug vimrc_CursorTrack au! "au WinLeave * match CursorTrack /\%#/ "au WinEnter * match none aug END "----------------------------------------------------------------------------- aug vimrc_colorscheme au! au ColorScheme * \ call CursorIM() | \ call StatusLineNC_fixer() | \ call Add_stl8tal_hl() | \ call Other_hl() aug END "" 日本語入力ON時のカーソルの色を設定 function! s:CursorIM() "{{{ if has('multi_byte_ime') || has('xim') highlight CursorIM guibg=#ffb700 guifg=NONE endif endfunction "}}} "StatusLine, TabLine で使うhighlight function! s:StatusLineNC_fixer() "{{{ "c] StatusLine のhlを取得してguibg guifgを取得 hi StatusLineNC term=reverse cterm=reverse gui=NONE guibg=Gray80 guifg=Black endfunction "}}} function! s:Add_stl8tal_hl() "{{{ hi User9 gui=bold guifg=darkblue guibg=lightcyan hi User8 gui=bold guifg=darkcyan guibg=lightblue hi User7 gui=bold guifg=moccasin guibg=hotpink hi TabLineInfo term=reverse ctermfg=Black ctermbg=LightBlue guifg=black guibg=lightblue hi ShujuuMaster guibg=indianred3 ctermbg=darkred hi ShujuuServant guibg=darkslategray4 ctermbg=darkgreen hi ShujuuSlave guibg=royalblue4 ctermbg=blue hi User1 guibg=indianred3 ctermbg=darkred hi User2 guibg=darkslategray4 ctermbg=darkgreen hi User3 guibg=royalblue4 ctermbg=blue hi TDD_Red guibg=indianred3 ctermbg=darkred "exe 'hi '. substitute(substitute(s:__Gs_hi('TabLine'), 'guifg=\S\+\ze\s', 'guifg=magenta', ''), 'TabLine', 'TabLineWinnum', '') "exe 'hi '. substitute(substitute(s:__Gs_hi('TabLineSel'), 'guifg=\S\+\ze\s', 'guifg=magenta', ''), 'TabLineSel', 'TabLineSelWinnum', '') endfunction "}}} function! s:Other_hl() "{{{ hi Pmenu guifg=white guibg=#6A5CB4 gui=NONE hi CursorTrack guibg=darkslategray4 endfunction "}}} "a:groupnameの:hiを返す function! s:__Gs_hi(groupname) "{{{ redir => hl exe 'hi '. a:groupname redir END let hl = substitute(hl, '[\r\n]', '', 'g') "改行除く let hl = substitute(hl, 'xxx', '', '') return hl endfunction "}}} "============================================================================= "表示系 "不可視文字表示 se list lcs= se lcs +=tab:>- se lcs +=trail:_ "行末空白 se lcs +=extends:> "画面に表示しきれない (続く) se lcs +=precedes:< "画面に表示しきれない (続く) se lcs +=eol:$ "隙間を埋める文字 se fillchars= se fcs +=vert:\| se fcs +=stl:\ se fcs +=stlnc:\ se fcs +=fold:\ se fcs +=diff:- let &sbr = '> ' "折り返された行の先頭に表示する文字列 se cpo +=n "'sbr'を行番号の間に表示させる se guioptions= "se go +=c "単純な選択にはポップアップダイアログでなくコンソールダイアログを使う se go +=r "右スクロールバーを常に表示 se go +=L "垂直分割されたとき左スクロールバーを表示 "se go +=m "menubar se go +=g "無効の menubar 項目を灰色表示 "逐次表示されるメッセージ se shortmess= se shm +=a "ステータス省略表現を使用 se shm +=O "読み込み、Quickfix関係のメッセージがその前のメッセージを上書きする se shm +=T "メッセージが長すぎてコマンドラインに収まらないときは中央を切り詰め se shm +=W "書き込み時、メッセージを表示しない se shm +=o "書き込み時のメッセージをその後の読み込みメッセージで上書きする se shm +=I "Vim開始挨拶メッセージを表示しない "============================================================================= "Gvim "----------------------------------------------------------------------------- "colorscheme siicEvening "エラー時の音とビジュアルベルの抑制 au GUIEnter * set vb t_vb= "Font "{{{ if has('win32') set gfn=MeiryoKe_Gothic:h8:cSHIFTJIS,\ MS_Gothic:h10:cSHIFTJIS if hostname() == 'SIICP11ALJ' set gfn=Migu_1M:h13:cSHIFTJIS,\ MS_Gothic:h14:cSHIFTJIS endif if hostname() == 'ATSUTO' "set gfn=Migu_1M:h15:cSHIFTJIS,\ MS_Gothic:h14:cSHIFTJIS "set gfn=Migu_1M:h17:cSHIFTJIS,\ MS_Gothic:h14:cSHIFTJIS set gfn=Migu_1M:h11:cSHIFTJIS,\ MS_Gothic:h10:cSHIFTJIS endif "set gfn=Migu_1M:h9:cSHIFTJIS,\ MS_Gothic:h10:cSHIFTJIS set linespace=2 elseif has('mac') set guifont=Osaka-等幅:h14 elseif has('xfontset') set guifontset=a14,r14,k14 set linespace=0 else endif "}}} if filereadable(fnamemodify('~/.privacy/.vimrc_privacy.vim', ':p')) source ~/.privacy/.vimrc_privacy.vim "lingr.vimのパスワードとか endif "============================================================================= "ファイルタイプ設定 au BufRead,BufNewFile *.markdown,*.md set ft=markdown autocmd FileType js setlocal ft=javascript augroup gitcommit au! au FileType gitcommit setl nofoldenable tw=60 augroup END au FileType snippet setl nofoldenable aug vimrc_help au! au FileType help nnoremap q c aug END aug vimrc_vim au! au FileType vim \ inoremap \ \ getline('.') =~ '^\s*$' ? "\\\" : match(getline('.'), '\S')+1 >= col('.') ? "\\\" : '\' aug END aug qf au! au FileType qf \ noremap q :cclose| \ noremap :.cc| \ endif aug END "============================================================================= "Mapping Basis let mapleader = '\' let maplocalleader = '_' noremap [space] nmap [space] nmap [C-k] nmap [C-g] "----------------------------------------------------------------------------- "No operation "インサートモードで間違って出してほしくないキー nnoremap noremap noremap! noremap noremap! noremap noremap! inoremap cnoremap inoremap "誤爆防止 nnoremap ZZ nnoremap q noremap zq q noremap z@ @ "勝手なマークを付けさせない noremap m "----------------------------------------------------------------------------- "Substitute noremap ; : noremap + ; noremap - ^ noremap S $ nnoremap j gj|nnoremap k gk|vnoremap j gj|vnoremap k gk call submode#enter_with('gjgk', 'nv', '', 'gj', 'gj') call submode#enter_with('gjgk', 'nv', '', 'gk', 'gk') call submode#leave_with('gjgk', 'nv', '', '') call submode#map('gjgk', 'nv', '', 'j', 'gj') call submode#map('gjgk', 'nv', '', 'k', 'gk') "nnoremap gj j|nnoremap gk k|vnoremap gj j|vnoremap gk k nnoremap z "----------------------------------------------------------------------------- "Alternative "undoフラグはctrlを押しっぱなしでも有効 inoremap u "----------------------------------------------------------------------------- "Compensation "; , call submode#enter_with('nextChar', 'nv', '', 'z;', ';') call submode#enter_with('nextChar', 'nv', '', 'z,,', ',') call submode#leave_with('nextChar', 'nv', '', 'z') call submode#map('nextChar', 'nv', '', ';', ';') call submode#map('nextChar', 'nv', '', ',', ',') noremap z- - "----------------------------------------------------------------------------- "インサートモードでの削除コマンドにundoを有効化させる inoremap u inoremap u "inoremap u "============================================================================= "Mapping Normal "----------------------------------------------------------------------------- "Normal modeで挿入 nnoremap :call Insert_CR() function! s:Insert_CR() "{{{ let foldclosedend = foldclosedend('.') if foldclosedend != -1 call append(foldclosedend, '') else call append('.', '') endif normal j endfunction "}}} nnoremap [C-k] :i. nnoremap [space] :i. "空白を挿入する nnoremap [space]a a nnoremap a nnoremap [space]i i nnoremap [space]s ilah "----------------------------------------------------------------------------- let s:bind_win = 'm' "Win/Buf Open/Close"{{{ "nnoremap [space]K :exe 'h '.expand('')swW nnoremap [space]K } exe 'nnoremap '. s:bind_win. 's s' exe 'nnoremap '. s:bind_win. 'b v' exe 'nnoremap '. s:bind_win. 'o o' "現在Bufを新しいタブページで開く nnoremap ; :tab split exe 'nnoremap '. s:bind_win. 'v :tab split' "ウィンドウレイアウトを保持したままバッファを閉じるコマンド com! KeepWinBd let kwbd_bn= bufnr("%") |bn |exe "bd ".kwbd_bn |unlet kwbd_bn nmap dm bd noremap bd :bd nmap dn KeepWinBd noremap KeepWinBd :KeepWinBd nmap dq c exe 'nnoremap '. s:bind_win. 'q c' exe 'nnoremap '. s:bind_win. 'dd c' nmap dv tabc nmap dgt tabc noremap tabc :tabc "指定した番号の窓を閉じる nmap ct Cls_remoteWin1 nmap cz Cls_remoteWin$ nmap c1 Cls_remoteWin1 nmap c2 Cls_remoteWin2 nmap c3 Cls_remoteWin3 nmap c4 Cls_remoteWin4 nmap c5 Cls_remoteWin5 nmap c6 Cls_remoteWin6 nmap d,t Cls_remoteWin1 nmap d,z Cls_remoteWin$ nmap d,1 Cls_remoteWin1 nmap d,2 Cls_remoteWin2 nmap d,3 Cls_remoteWin3 nmap d,4 Cls_remoteWin4 nmap d,5 Cls_remoteWin5 nmap d,6 Cls_remoteWin6 nmap mdt Cls_remoteWin1 nmap mdz Cls_remoteWin$ nmap md1 Cls_remoteWin1 nmap md2 Cls_remoteWin2 nmap md3 Cls_remoteWin3 nmap md4 Cls_remoteWin4 nmap md5 Cls_remoteWin5 nmap md6 Cls_remoteWin6 nnoremap Cls_remoteWin$ :call Cls_remoteWin(winnr('$')) nnoremap Cls_remoteWin1 :call Cls_remoteWin(1) nnoremap Cls_remoteWin2 :call Cls_remoteWin(2) nnoremap Cls_remoteWin3 :call Cls_remoteWin(3) nnoremap Cls_remoteWin4 :call Cls_remoteWin(4) nnoremap Cls_remoteWin5 :call Cls_remoteWin(5) nnoremap Cls_remoteWin6 :call Cls_remoteWin(6) function! s:Cls_remoteWin(winnr) "{{{ let save_winnr = winnr() exe a:winnr. 'wincmd w' hide if save_winnr == a:winnr return endif let save_winnr = s:__Gv_adjust_saveWinnr(save_winnr, [a:winnr]) exe save_winnr. 'wincmd w' endfunction "}}} "特殊窓を遠隔で閉じるコマンド nmap cq Close_allSpecialWins nmap d,q Close_allSpecialWins nnoremap Close_allSpecialWins :call Close_allSpecialWins({'option': ['&pvw'], 'bt': ['quickfix'], 'ft': ['unite']}) function! s:Close_allSpecialWins(spclTypes) "{{{ let save_winnr = winnr() let killedwinnr_list = [] windo call add(killedwinnr_list, s:__chk8kill_SpclWin_winnr(a:spclTypes)) let save_winnr = s:__Gv_adjust_saveWinnr(save_winnr, killedwinnr_list) exe save_winnr.'wincmd w' endfunction "}}} function! s:__chk8kill_SpclWin_winnr(spclTypes) "{{{ if s:___jg_spclWin(a:spclTypes) let winnr = winnr() hide return winnr endif endfunction "}}} function! s:___jg_spclWin(spclTypes) "{{{ let result = 0 for pcd in a:spclTypes.option if pcd return 1 endif endfor for pcd in a:spclTypes.bt if &bt ==# pcd return 1 endif endfor for pcd in a:spclTypes.ft if &ft ==# pcd return 1 endif endfor endfunction "}}} function! s:__Gv_adjust_saveWinnr(save_winnr, killedwinnr_list) "{{{ let save_winnr = a:save_winnr for killedwinnr in reverse(a:killedwinnr_list) if killedwinnr == 0 continue endif if killedwinnr < save_winnr let save_winnr -= 1 endif endfor return save_winnr endfunction "}}} "}}} "----------------------------------------------------------------------------- "Win/Buf Switching"{{{ "次/前のバッファおよび次/前タブページへ nnoremap :bp nnoremap :bn nnoremap [space]h :bp nnoremap [space]l :bn nnoremap gr gT nnoremap [space]n gt nnoremap [space]p gT nnoremap [C-g] gt nnoremap [C-g]g gT nnoremap :tabp nnoremap :tabn "次のウィンドウ・前のウィンドウへ nnoremap w nnoremap W nnoremap [space]j :call Roop_switchWin("j") nnoremap [space]k :call Roop_switchWin("k") exe 'nnoremap '. s:bind_win. 'h :call Roop_switchWin("h")' exe 'nnoremap '. s:bind_win. 'j :call Roop_switchWin("j")' exe 'nnoremap '. s:bind_win. 'k :call Roop_switchWin("k")' exe 'nnoremap '. s:bind_win. 'l :call Roop_switchWin("l")' function! s:Roop_switchWin(bind) "{{{ let save_winnr = winnr() exe 'wincmd '. a:bind if winnr() == save_winnr let antiBind = a:bind=='h'?'l' : a:bind=='j'?'k' : a:bind=='k'?'j' : 'h' exe '16wincmd '. antiBind endif endfunction "}}} "指定した窓に跳ぶ nnoremap [space]1 1 nnoremap [space]2 2 nnoremap [space]3 3 nnoremap [space]4 4 nnoremap [space]5 5 nnoremap [space]6 6 exe 'nnoremap '. s:bind_win. '1 1' exe 'nnoremap '. s:bind_win. '2 2' exe 'nnoremap '. s:bind_win. '3 3' exe 'nnoremap '. s:bind_win. '4 4' exe 'nnoremap '. s:bind_win. '5 5' exe 'nnoremap '. s:bind_win. '6 6' "タブページを手繰る nnoremap [C-g]o :tabonly|"現在タブページ以外を閉じる nnoremap [C-g]c :tabclose|"タブページ閉じる nnoremap [C-g]fv :tabe $VIM/.vimrc nnoremap [C-g]] :execute "tab tag ".expand('')|"カーソルドタグを新規タブページで開く nnoremap [C-g][ :execute "tab help ".expand('')|"カーソルドワードを新規タブページで:helpする nnoremap [C-g]K :execute "tab help ".expand('')|"カーソルドワードを新規タブページで:helpする "}}} "----------------------------------------------------------------------------- "表示・GUI操作"{{{ nnoremap z :echo bufname("%")'['&fenc']['&ff']'(strftime("%Y-%m-%d %X",getftime(bufname("%")))) "["b:charCounterCount"字]" "0x"CursoredCharHex()"\n"FoldCCnavi() function! CursoredCharHex()"{{{ let c = matchstr(getline('.'), '.', col('.') - 1) let c = iconv(c, &enc, &fenc) return s:__byte2hex(s:__str2byte(c)) endfunction function! s:__str2byte(str) return map(range(len(a:str)), 'char2nr(a:str[v:val])') endfunction function! s:__byte2hex(bytes) return join(map(copy(a:bytes), 'printf("%02X", v:val)'), '') endfunction "}}} nnoremap me :mes "nnoremap ma :marks nnoremap ma :Unite mark "Fontzoom let g:fontzoom_no_default_key_mappings = 1 call submode#enter_with('fontzoom', 'n', 'r', ',+', '(fontzoom-larger)') call submode#enter_with('fontzoom', 'n', 'r', ',-', '(fontzoom-smaller)') call submode#map('fontzoom', 'n', 'r', '+', '(fontzoom-larger)') call submode#map('fontzoom', 'n', 'r', '-', '(fontzoom-smaller)') ",zwmでgui窓を動かす let [g:wm_move_down, g:wm_move_up, g:wm_move_left, g:wm_move_right] = ['', '', '', ''] "{{{ call submode#enter_with('move-window', 'n', '', ',zwm', '') call submode#leave_with('move-window', 'n', '', '') call submode#map('move-window', 'n', 'r', 'j', '(winmove-down)') call submode#map('move-window', 'n', 'r', '', '(winmove-down)') call submode#map('move-window', 'n', 'r', 'k', '(winmove-up)') call submode#map('move-window', 'n', 'r', '', '(winmove-up)') call submode#map('move-window', 'n', 'r', 'h', '(winmove-left)') call submode#map('move-window', 'n', 'r', '', '(winmove-left)') call submode#map('move-window', 'n', 'r', 'l', '(winmove-right)') call submode#map('move-window', 'n', 'r', '', '(winmove-right)') "}}} ",zwsで窓の高さ調整 call submode#enter_with('win-size', 'n', '', ',zws', '') "{{{ call submode#enter_with('win-size', 'n', '', '>', '>') call submode#enter_with('win-size', 'n', '', '<', '<') call submode#enter_with('win-size', 'n', '', '+', '+') call submode#enter_with('win-size', 'n', '', '-', '-') call submode#leave_with('win-size', 'n', '', '') call submode#map('win-size', 'n', '', 'j', '+') call submode#map('win-size', 'n', '', '', '+') call submode#map('win-size', 'n', '', 'k', '-') call submode#map('win-size', 'n', '', '', '-') call submode#map('win-size', 'n', '', 'h', '<') call submode#map('win-size', 'n', '', '', '<') call submode#map('win-size', 'n', '', 'l', '>') call submode#map('win-size', 'n', '', '', '>') call submode#map('win-size', 'n', 'x', '=', '=') "}}} nnoremap ,0 = exe 'nnoremap '. s:bind_win. '0 =' nnoremap ,\ _ nnoremap \ _ exe 'nnoremap '. s:bind_win. '\ _' exe 'nnoremap '. s:bind_win. 'J J' exe 'nnoremap '. s:bind_win. 'K K' exe 'nnoremap '. s:bind_win. 'H H' exe 'nnoremap '. s:bind_win. 'L L' "ある窓を大きく開く "nnoremap ,0 :call Enlarge_win(0) nnoremap ,1 :call Enlarge_win(1) nnoremap ,2 :call Enlarge_win(2) nnoremap ,3 :call Enlarge_win(3) nnoremap ,4 :call Enlarge_win(4) nnoremap ,5 :call Enlarge_win(5) nnoremap ,6 :call Enlarge_win(6) function! s:Enlarge_win(winnr) "{{{ let targetWinnr = a:winnr ? a:winnr : winnr() let save_winnr = winnr() let [save_wh, save_wiw] = [&wh, &wiw] set wh=20 wiw=20 exe targetWinnr. 'wincmd w' exe 'wincmd =' let [&wh, &wiw] = [save_wh, save_wiw] exe save_winnr. 'wincmd w' endfunction "}}} "}}} "----------------------------------------------------------------------------- "検索ハイライト noremap z/ :nohlsearch:sign unplace 333 "検索を手繰る sign define SearchStart text=索 texthl=Search nnoremap g/ :exe 'sign jump 333 buffer='.bufnr('%') noremap n :call Put_SearchStartSign(1)nzv function! s:Put_SearchStartSign(nN) "{{{ let [lnr, bufnr] = [line('.'), bufnr('%')] if a:nN "nNキーでの検索 silent let chksign = s:__Gs_signs1buf(bufnr) if chksign =~ '=333' return endif endif sign unplace 333 exe 'sign place 333 line='. lnr. ' name=SearchStart buffer='. bufnr endfunction function! s:__Gs_signs1buf(bufnr) redir => chksign exe 'sign place buffer='. a:bufnr redir END return chksign endfunction "}}} "visualstar.vim nmap * (visualstar-*)NPut_SearchStartSign vmap * (visualstar-*)NPut_SearchStartSign noremap Put_SearchStartSign :call Put_SearchStartSign(0) "map # (visualstar-#)N:sign unplace 333 "----------------------------------------------------------------------------- let s:bind_markj = '@' "カーソル移動コマンド(Normal,Omap)"{{{ noremap [space]w W noremap [space]b B noremap [space]e E noremap [space]ge gE omap W omap i iW omap a aW omap B omap E omap g gE "'%'コマンドを拡張する#Bible4-10 runtime macros/matchit.vim let b:match_ignorecase = 1 let b:batch_words = &matchpairs . ",\:\" "crrlineの次の括弧内に移動 noremap :call In_nextBracket() inoremap :call In_nextBracket() function! s:In_nextBracket() "{{{ call search('()\|[]\|{}\|<>\|''''\|""', '', line('.')+1) normal! l startinsert endfunction "}}} "一つ上or下の他窓をスクロールさせる noremap :call Scroll_other_win(1, "\C-e>") noremap :call Scroll_other_win(1, "\C-y>") noremap :call Scroll_other_win(1, "\C-b>") noremap :call Scroll_other_win(1, "\C-f>") inoremap :call Scroll_other_win(1, "\C-e>")a inoremap :call Scroll_other_win(1, "\C-y>")a let g:scroll_other_win_reverse = 0 function! s:Scroll_other_win(_above, bind) "{{{ let _above = a:_above if exists('g:scroll_other_win_reverse') && g:scroll_other_win_reverse let _above = !_above endif if _above wincmd W exe "normal ". a:bind wincmd w else wincmd w exe 'normal '. a:bind wincmd W endif endfunction "}}} "同じインデントレベルを移動 nn [space]] :call search ("^". matchstr (getline (line (".")), '\(\s*\)') ."\\S")^ nn [space][ k:call search ("^". matchstr (getline (line (".")+ 1), '\(\s*\)') ."\\S", 'b')^ "変更リストブラウズ call submode#enter_with('changelist', 'n', '', 'g,', 'g,zv') call submode#enter_with('changelist', 'n', '', 'g;', 'g;zv') call submode#leave_with('changelist', 'n', '', '') call submode#map('changelist', 'n', '', ',', 'g,zv') call submode#map('changelist', 'n', '', ';', 'g;zv') "mark jump exe 'noremap '. s:bind_markj. ' `' exe 'noremap '. s:bind_markj. '@ ``' exe 'noremap '. s:bind_markj. ' `"' "次の折り畳みに移動 call submode#enter_with('fd-jmp', 'n', '', 'zj', 'zj') call submode#enter_with('fd-jmp', 'n', '', 'zk', 'zk') call submode#leave_with('fd-jmp', 'n', '', '') call submode#map('fd-jmp', 'n', '', 'j', 'zj') call submode#map('fd-jmp', 'n', '', 'k', 'zk') call submode#map('fd-jmp', 'n', '', 't', '[z') call submode#map('fd-jmp', 'n', '', 'b', ']z') "noremap [space]n zj "noremap [space]p zk noremap [space]t [z noremap [space]z ]z "下二桁指定ジャンプ from ujm command! -count=1 -nargs=0 GoToTheLine silent execute getpos('.')[1][:-len(v:count)-1] . v:count nnoremap gl :GoToTheLine "}}} "----------------------------------------------------------------------------- "折り畳み操作 noremap :call Smart_FoldCloser() function! s:Smart_FoldCloser() "{{{ if foldlevel('.') == 0 normal! zM return endif let foldclosedRslt = foldclosed('.') if foldclosedRslt == -1 normal! zc return endif normal! zc if foldclosed('.') != foldclosedRslt return endif normal zM endfunction "}}} "nnoremap zf A ^:setl rnuzf nnoremap zf A ^zf nnoremap l foldclosed(line('.')) != -1 ? 'zo' : 'l' nnoremap [C-k]m zM nnoremap [C-k]r zR nnoremap [space] zM nnoremap [space]m zM nnoremap [space]r zR au BufEnter,FileType * :call FoldmarkerAppend() function! FoldmarkerAppend() let cmsStart = matchstr(&cms,'\V\s\*\zs\.\+\ze%s') let cmsEnd = matchstr(&cms,'\V%s\zs\.\+') let fmr = split(&fmr,',') exe 'nnoremap [C-k][[ A '.cmsStart.fmr[0].cmsEnd.'^' exe 'nnoremap [C-k]]] A '.cmsStart.fmr[1].cmsEnd.'^' exe 'nnoremap [C-k][] A'.cmsStart.'===== '.fmr[0].'1 '.fmr[1].'1'.cmsEnd.'^' exe 'nnoremap [C-k][1 A '.cmsStart.fmr[0].'1'.cmsEnd.'^' exe 'nnoremap [C-k][2 A '.cmsStart.fmr[0].'2'.cmsEnd.'^' exe 'nnoremap [C-k][1 A '.fmr[0].'1'.cmsEnd.'^' exe 'nnoremap [C-k][2 A '.fmr[0].'2'.cmsEnd.'^' exe 'nnoremap [C-k]]1 A '.cmsStart.fmr[1].'1'.cmsEnd.'^' exe 'nnoremap [C-k]]2 A '.cmsStart.fmr[1].'2'.cmsEnd.'^' exe 'nnoremap [C-k]1[ A '.fmr[0].'1'.cmsEnd.'^' exe 'nnoremap [C-k]2[ A '.fmr[0].'2'.cmsEnd.'^' exe 'nnoremap [C-k]1] A '.fmr[1].'1'.cmsEnd.'^' exe 'nnoremap [C-k]2] A '.fmr[1].'2'.cmsEnd.'^' endfunction "----------------------------------------------------------------------------- "編集コマンド(Normal) let s:bind_reg = '' nnoremap ,w :w nnoremap ,q :qa map Y y$ noremap "+ exe 'nnoremap '. s:bind_reg. ' "' exe 'nnoremap '. s:bind_reg. ' "+' exe 'nnoremap '. s:bind_reg. '8 "+' map [C-g]y "*y map [C-g]d "*d map [C-g]p "*p "コメントアウト "[削]を付ける nmap [cm]d :call CommeToggleDelMarker() function! s:CommeToggleDelMarker() "{{{ let cmsstart = matchstr(&cms,'\V\s\*\zs\.\+\ze%s') let cmsend = matchstr(&cms,'\V%s\zs\.\+') let crrstr = getline('.') if matchstr(crrstr, '\[削]') == '[削]' call setline('.',substitute(crrstr, cmsstart.'\[削]', '', 'g')) else exe 'normal! I'.cmsstart.'[削]' endif endfunction "}}} "★を挿入する nmap [cm]o :call CommeAddStar(0) nmap [cm]O :call CommeAddStar(1) function! s:CommeAddStar(append) "{{{ let cmsstart = matchstr(&cms,'\V\s\*\zs\.\+\ze%s') let cmsend = matchstr(&cms,'\V%s\zs\.\+') if a:append exe 'normal! O'.cmsstart.'★' else exe 'normal! o'.cmsstart.'★' endif endfunction "}}} "直前のコマンドを再度実行する "nnoremap ,. q:k nnoremap @: @: "ペーストしたテキストを再選択するBible3-15 nnoremap gb '`[' . strpart(getregtype(), 0,1) . '`]' onoremap gb :normal gb onoremap @@ :normal gb onoremap gv :normal gv "前回保存した状態にまでアンドゥ nnoremap [space]u :earlier 1f "タグ検索をUniteで置き換える "nnoremap :UniteWithCursorWord -immediately tag "----------------------------------------------------------------------------- "設定を切り替える nmap [space]o [op] "{{{ "文字コード nnoremap [op]7 :se fenc=euc-jp nnoremap [op]8 :se fenc=utf-8 nnoremap [op]9 :se fenc=cp932 nnoremap ,7 :se fenc=euc-jp nnoremap ,8 :se fenc=utf-8 nnoremap ,9 :se fenc=cp932 nnoremap [op]- :let &ff = &ff=='dos' ? 'unix' : &ff=='unix' ? 'mac' : 'dos' "タブ nnoremap [op]e :setlocal expandtab! expandtab? nnoremap [op]t2 :setl ts=2 sw=2 sts=2 nnoremap [op]t4 :setl ts=4 sw=4 sts=4 nnoremap [op]t8 :setl ts=8 sw=8 sts=8 "見た目 nnoremap [op]r :let &rnu = !&rnu nnoremap [op]n :let &nu = !&nu nnoremap [op]l :let &list = !&list nnoremap [op]m :if &go=~'m'| set go-=m| else| set go+=m| endif nnoremap [op]cc :let &cc = empty(&cc) ? '+1' : '' nnoremap [op]cg :let &cuc = !&cuc nnoremap [op]cl :let &cul = !&cul nnoremap [op]co :let &cole = &cole==0 ? 3 : 0:se cole? nnoremap [op]w :se wrap! wrap? nnoremap [op]fm :let &fdm = &fdm=='marker'?'expr':&fdm=='expr'?'diff':'marker':se fdm? "挙動 nnoremap [op]a :se ai! ai? set pastetoggle= "NOTE: paste mode 中は'ai'無効 "&foに ro を加えたり外したり(コメント文字自動挿入) nnoremap [op]fr :if &fo=~'[ro]'| setl fo-=ro| echo 'fo -=ro'| else| setl fo+=ro| echo 'fo +=ro'|endif "&foに t を加えたり外したり(&tw自動折り返し) nnoremap [op]ft :if &fo=~'[tc]'| setl fo-=tc| echo 'fo -=tc'| else| setl fo+=tc| echo 'fo +=tc'|endif nnoremap [op]sw :se ws! ws? nnoremap [op]sc :se ic! ic? nnoremap [op]si :se is! is? nnoremap [op]v :let &vbs = &vbs==0?12:0:se vbs? "バッファ属性 nnoremap [op]M :let &ma = !&ma nnoremap [op]R :let &ro = !&ro nnoremap [op]W :let &write = !&write nnoremap [op]cb :se crb! crb? nnoremap [op]sf :se swf! swf? "スクリプトの変数など nnoremap [op]ps :let g:scroll_other_win_reverse = !g:scroll_other_win_reverse:echo 'scroll reverse'.g:scroll_other_win_reverse "}}} nnoremap t :call multikey_effect() function! s:multikey_effect() "{{{ if &rnu == 0 setl rnu else setl number endif endfunction "}}} "----------------------------------------------------------------------------- "あるバッファを開く ".vimrcをすぐに開くコマンド "nnoremap ,ov :e $MYVIMRC nnoremap ,ov :e ~/dotfiles/.vimrc nnoremap ,og :e ~/.gitconfig "junkFile "noremap ,oj :JunkFile "vimscripttips "noremap ,ot :e ~/vimscripttips.vim "ファイルタイプを追加する "自動でバックアップするタイプになる "noremap ,t :set filetype+=.autowrite "noremap ,T :set filetype-=.autowrite| \ if exists('#autowrite')| augroup! autowrite| endif nnoremap ,xv :ReloadVimrc nnoremap [C-k]v :ReloadVimrc nnoremap [C-k]s :so % nnoremap [C-g] ":\h " "----------------------------------------------------------------------------- "テスト変数 nnoremap [C-k]tu :unlet g:test01 |unlet g:test02 |unlet g:test03 |unlet g:test04 nnoremap [C-k]tt :call display_test_vars() nnoremap [C-k]tk :call PeekEcho() function! s:display_test_vars() "{{{ let display = '' if exists('g:test01') let display .= 'g:test01='. string(g:test01)."\n" endif if exists('g:test02') let display .= 'g:test02='. string(g:test02)."\n" endif if exists('g:test03') let display .= 'g:test03='. string(g:test03)."\n" endif if exists('g:test04') let display .= 'g:test04='. string(g:test04) endif echo display endfunction "}}} "============================================================================= "Mapping Visual vnoremap v $h vnoremap zf :call Fixed_zf() function! s:Fixed_zf() range "{{{ let cmsStart = matchstr(&cms,'\V\s\*\zs\.\+\ze%s') let cmsEnd = matchstr(&cms,'\V%s\zs\.\+') let fmr = split(&fmr,',') call setline(a:firstline, getline(a:firstline). ' '. cmsStart.fmr[0].cmsEnd) call setline(a:lastline, getline(a:lastline). cmsStart.fmr[1].cmsEnd) endfunction "}}} "0,0,0などの並んだ数字を選択して連番にするコマンドhttp://d.hatena.ne.jp/fuenor/20090907/1252315621 vnoremap :ContinuousNumber vnoremap :ContinuousNumber command! -count -nargs=1 ContinuousNumber \ let c = col('.')|for n in range(1, ?-line('.'):1)|exec 'normal! j' . n . |call cursor('.', c)|endfor "============================================================================= "Mapping Insert & CommandLine "----------------------------------------------------------------------------- let s:bind_comp = 'l' let s:bind_snip = 's' "InsertMode, CommandLineでの移動コマンド"{{{ inoremap inoremap inoremap inoremap cnoremap cnoremap cnoremap cnoremap inoremap inoremap cnoremap cnoremap "}}} "InsertModeでのみの移動コマンド {{{ "inoremap pumvisible() ? "\" : "\" "inoremap pumvisible() ? "\" : "\" "inoremap getline('.')[col('.')-2] =~ '[)}>"''\]]' ? "\" : "\" "inoremap :call bracketTour()i "インサートモード用。以前の括弧に飛ぶ function! s:bracketTour() "{{{ let col =col('.') call search('()\|''''\|""\|[]\|{}\|<>','bW',line('.')) if col('.') == col normal! ^ return endif normal! l endfunction"}}} "call submode#enter_with('brackets', 'i', '', '(', '(') "call submode#enter_with('brackets', 'i', '', '<', '<') "call submode#enter_with('brackets', 'i', '', '[', '[') "call submode#enter_with('brackets', 'i', '', '{', '{') "call submode#enter_with('brackets', 'i', '', "'", "'") "call submode#enter_with('brackets', 'i', '', '"', '"') "call submode#leave_with('brackets', 'i', '', '') "call submode#map('brackets', 'i', '', '(', '(') "call submode#map('brackets', 'i', '', '<', '<') "call submode#map('brackets', 'i', '', '[', '[') "call submode#map('brackets', 'i', '', '{', '{') "call submode#map('brackets', 'i', '', "'", "'") "call submode#map('brackets', 'i', '', '"', '"') "call submode#map('brackets', 'i', '', ')', ')') "call submode#map('brackets', 'i', '', '>', '>') "call submode#map('brackets', 'i', '', ']', ']') "call submode#map('brackets', 'i', '', '}', '}') "call submode#map('brackets', 'i', 'x', '', '') "}}} "----------------------------------------------------------------------------- "InsertMode, CommandLineでの編集コマンド inoremap cnoremap inoremap + cnoremap + inoremap " cnoremap " inoremap + cnoremap + inoremap @ + cnoremap @ + inoremap 8 + cnoremap 8 + inoremap + cnoremap + inoremap expand('%:t') cnoremap expand('%:t') "バックスラッシュとかバーが打ちづらいから inoremap \ cnoremap \ inoremap cnoremap inoremap cnoremap vnoremap "----------------------------------------------------------------------------- "InsertModeでの編集コマンド inoremap "< 直前の挿入を再度挿入 inoremap inoremap "入力した文字を大文字・小文字化(from thinca) inoremap gUvbgi inoremap guvbgi imap imap imap "----------------------------------------------------------------------------- "CommandLineでの編集コマンド "cnoremap " "編集中のファイルの場所をカレントディレクトリに設定する cnoremap %:h cnoremap "h " "TODO 現在のコマンドラインをyankする "cnoremap "============================================================================= "コマンドラインウィンドウ cnoremap nnoremap q: nnoremap c; q: xnoremap c; q: "コマンドラインウィンドウのキーマップを使いやすいように変更 autocmd CmdwinEnter * call s:init_cmdwin() function! s:init_cmdwin() nnoremap q :quit nnoremap :quit inoremap pumvisible() ? "\\" : "\" inoremap pumvisible() ? "\\" : "\" inoremap pumvisible() ? "\\" : "\" " Completion. inoremap pumvisible() ? "\" : "\" startinsert! endfunction "============================================================================= "Commands " ヘルプを別のタブで開く command! -nargs=* -complete=help TH tab help AlterCommand th TH ".vimrcをリロードする command! ReloadVimrc source $MYVIMRC AlterCommand rv ReloadVimrc "パターンとファイル名を逆にしたgrep command! -complete=file -nargs=+ Perg call s:perg([]) function! s:perg(args) execute 'vimgrep' '/'.a:args[-1].'/' join(a:args[:-2]) endfunction AlterCommand perg Perg "現在ファイルのあるディレクトリでvimgrep command! -nargs=+ CurrentGrep call s:CurrentGrep([]) function! s:CurrentGrep(args) execute 'vimgrep' '/'.a:args[0].'/ '.expand(a:args[1]).'/**/*' cwindow endfunction AlterCommand crrg[rep] CurrentGrep " Open junk file.(Hack#181)"{{{ command! -nargs=0 JunkFile call s:open_junk_file() function! s:open_junk_file() let l:junk_dir = $HOME . '/.vim_junk'. strftime('/%Y/%m') if !isdirectory(l:junk_dir) call mkdir(l:junk_dir, 'p') endif let l:filename = input('Junk Code: ', l:junk_dir.strftime('/%Y-%m-%d-%H%M%S.')) if l:filename != '' execute 'edit ' . l:filename endif endfunction "}}} "失敗したaugを無効にする command! -nargs=1 -complete=augroup KillAug call KillAug() command! -nargs=1 -complete=augroup AugKiller call KillAug() function! s:KillAug(augname) "{{{ exe 'aug '. a:augname au! aug END endfunction "}}} command! -nargs=* -complete=file -bang Rename :call Rename("", "") function! s:Rename(name, bang) "{{{ let crrpath = expand("%:p") let v:errmsg = "" silent! exe "saveas" . a:bang . " " . a:name if v:errmsg =~# '^$\|^E329' if expand("%:p") !=# crrpath && filewritable(expand("%:p")) silent exe "bwipe! " . crrpath if delete(crrpath) echoerr "Could not delete " . crrpath endif endif else echoerr v:errmsg endif endfunction "}}} AlterCommand ren[ame] Rename "============================================================================= "ミニプラグイン " Call a script local function."{{{ " Usage: " - S('local_func') " -> call s:local_func() in current file. " - S('plugin/hoge.vim:local_func', 'string', 10) " -> call s:local_func('string', 10) in *plugin/hoge.vim. " - S('plugin/hoge:local_func("string", 10)') " -> call s:local_func("string", 10) in *plugin/hoge(.vim)?. function! S(f, ...) let [file, func] =a:f =~# ':' ? split(a:f, ':') : [expand('%:p'), a:f] let fname = matchstr(func, '^\w*') " Get sourced scripts. redir =>slist scriptnames redir END let filepat = '\V' . substitute(file, '\\', '/', 'g') . '\v%(\.vim)?$' for s in split(slist, "\n") let p = matchlist(s, '^\s*\(\d\+\):\s*\(.*\)$') if empty(p) continue endif let [nr, sfile] = p[1 : 2] let sfile = fnamemodify(sfile, ':p:gs?\\?/?') if sfile =~# filepat && \ exists(printf("*\%d_%s", nr, fname)) let cfunc = printf("\%d_%s", nr, func) break endif endfor if !exists('nr') echoerr Not sourced: ' . file return elseif !exists('cfunc') let file = fnamemodify(file, ':p') echoerr printf( \ 'File found, but function is not defined: %s: %s()', file, fname) return endif return 0 <= match(func, '^\w*\s*(.*)\s*$') \ ? eval(cfunc) : call(cfunc, a:000) endfunction"}}} "指定したスクリプトファイルのスクリプトローカル変数を取得する - くふくふん"{{{ command! SV echo ScriptVars(PathToSNR(expand('%:p'))) function! ScriptVarSource() return "function! s:__get_script_variables()\n \ return s:\n \ endfunction" endfunction function! ScriptVars(snr) return eval('{a:snr}___get_script_variables()') endfunction function! ScriptVar(snr, var_name) let d = ScriptVars(a:snr) if !has_key(d, a:var_name) throw 'ScriptVar: not found script variable "' . a:var_name . '".' endif return get(d, a:var_name) endfunction function! PathToSNR(path) redir => _ silent scriptnames redir END redraw! let names = split(_, "\n") call filter(names, "matchstr(v:val, '^\\s*\\d*: \\zs.*') ==# a:path") if empty(names) throw 'PathToSNR: not convert the path "' . a:path . '".' endif return str2nr(matchstr(names[0], '^\s*\d*')) endfunction "}}} "" Show the diff between the current buffer and the last saved file. (from thinca) {{{ "XXX: diff自体がうまく機能しなかった " "let g:V = vital#of('vital').load( "\ ['System.Filepath'], "\ ['Data.String']) " "nnoremap ,fw :call diff_original() "function! s:diff_original() " if exists('b:diff_current') " execute bufwinnr(b:diff_current) 'wincmd w' " endif " if exists('b:diff_original') " diffoff " execute b:diff_original 'bwipeout' " unlet b:diff_original " return " endif " " let bufnr = bufnr('%') " let ft = &l:filetype " let fenc = &l:fileencoding " " if &modified " let source = '#' . bufnr " let file = '[last save]' " endif " if !exists('source') " silent! call g:V.system('svn info') " if !g:V.get_last_status() " let source = '!svn cat #' . bufnr " let file = '[svn HEAD]' " endif " endif " if !exists('source') " silent! call g:V.system('bzr info') " if !g:V.get_last_status() " let source = '!bzr cat #' . bufnr " let file = '[bzr tip]' " endif " endif " if !exists('source') " silent! let git_dir = g:V.system('git rev-parse --git-dir') " if git_dir !=# '' " let source = '!git cat-file blob HEAD:' . " \ expand('#' . bufnr . ':p')[strlen(fnamemodify(git_dir, ':p')) - 5:] " let source = substitute(source, '\\', '/', 'g') " let file = '[git HEAD]' " endif " endif " " if !exists('source') " echo 'There is not the diff.' " return " endif " " vertical new " " let b:diff_current = bufnr " let bufnr = bufnr('%') " setlocal buftype=nofile " let &l:filetype = ft " let &l:fileencoding = fenc " file `=file . fnamemodify(bufname(b:diff_current), ':.')` " " silent! execute 'read' source " " 0 delete _ " diffthis " wincmd p " diffthis " let b:diff_original = bufnr "endfunction "" }}} "YankRingっぽくyank/historiesを使う nnoremap [space]@ :call Keyswitcher#switch('r', 'n') call Keyswitcher#map('n', ['r', 's'], '', ['(yank-replace-n)', ':cn']) call Keyswitcher#map('n', ['r', 's'], '', ['(yank-replace-p)', ':cp']) noremap (yank-replace-n) :call Yank_replace(1) noremap (yank-replace-p) :call Yank_replace(-1) let s:yank_histories_replace_idx = 0 function! s:Yank_replace(fluct) "{{{ let yank_histories = s:__get_yank_histories() if exists('s:yank_histories_cache') && s:yank_histories_cache != yank_histories let s:yank_histories_replace_idx = 0 endif let s:yank_histories_cache = copy(yank_histories) let yank_histories_len = len(yank_histories) let s:yank_histories_replace_idx += a:fluct let s:yank_histories_replace_idx = s:yank_histories_replace_idx>=yank_histories_len? 0 \ : s:yank_histories_replace_idx<0 ? yank_histories_len-1 \ : s:yank_histories_replace_idx echo s:yank_histories_replace_idx let replace_content = get(yank_histories, s:yank_histories_replace_idx, '') let [bgn, end] = [line("'["), line("']")] if bgn != line('.') || bgn == 0 || end == 0 return endif let [save_reg, save_regtype] = [getreg('"'), getregtype('"')] call setreg('"', replace_content,) silent exe 'normal! u' silent exe 'normal! '. (0? 'gv' :''). '""'. 'p' call setreg('"', save_reg, save_regtype) endfunction "}}} function! s:__get_yank_histories() "{{{ let l = [] let c = unite#sources#history_yank#define().gather_candidates('','') for pkd in c call add(l, pkd.word) endfor return l endfunction "}}} "============================================================================= " 各種プラグイン設定 "----------------------------------------------------------------------------- "プラグイン 拡張インターフェイス "quickrun.vim nmap ,xq (quickrun) let g:quickrun_config = {} let g:quickrun_config['markdown'] = { \ 'type': 'markdown/kramdown', \ 'cmdopt': '-s', \ 'outputter': 'browser' \ } "let g:quickrun_config['sysdraft.vim'] = {'type': 'vim'} "lingr-vim au FileType lingr-messages nnoremap \ :LingrExit noremap ,xl :call lingrlaunch_in_newtab() function! s:lingrlaunch_in_newtab()"{{{ tabnew LingrLaunch exe 3 . "wincmd w" endfunction "}}} "ref.vim"{{{ au FileType ref-* nnoremap q :close let g:ref_phpmanual_path = 'D:/dic/vim-ref/php-chunked-xhtml' "webdictサイトの設定 let g:ref_source_webdict_sites = {} let g:ref_source_webdict_sites.je = {'url': 'http://dictionary.infoseek.ne.jp/jeword/%s',} let g:ref_source_webdict_sites.ej = {'url': 'http://dictionary.infoseek.ne.jp/ejword/%s',} let g:ref_source_webdict_sites.kok = {'url': 'http://dictionary.infoseek.ne.jp/word/%s?dic=daijisen',} let g:ref_source_webdict_sites.wip = {'url': 'http://ja.wikipedia.org/wiki/%s',} let g:ref_source_webdict_sites.default = 'ej' let g:ref_source_webdict_encoding = 'cp932' "出力に対するフィルタ。最初の数行を削除 function! g:ref_source_webdict_sites.je.filter(output) return join(split(a:output, "\n")[15 :], "\n") endfunction function! g:ref_source_webdict_sites.ej.filter(output) return join(split(a:output, "\n")[15 :], "\n") endfunction function! g:ref_source_webdict_sites.kok.filter(output) return join(split(a:output, "\n")[15 :], "\n") endfunction function! g:ref_source_webdict_sites.wip.filter(output) return join(split(a:output, "\n")[17 :], "\n") endfunction nnoremap ,zj :Ref webdict je nnoremap ZJ :Ref webdict je nnoremap ,zh :Ref webdict ej nnoremap ZH :Ref webdict ej nnoremap ,zk :Ref webdict kok nnoremap ZK :Ref webdict kok nnoremap ,zw :Ref webdict wip nnoremap ZW :Ref webdict wip AlterCommand zh Ref webdict ej AlterCommand zj Ref webdict je AlterCommand zk Ref webdict kok AlterCommand zw Ref webdict wip "}}} "ctrlp.vim "{{{ nnoremap [C-k] :CtrlP nnoremap [C-k] :CtrlPBuffer nnoremap [C-k] :CtrlPMRU let g:ctrlp_use_migemo = 1 let g:ctrlp_switch_buffer = 'Et' let g:ctrlp_reuse_window = 'netrw\|help\|quickfix\|vimfiler\|unite\|vimshell' let g:ctrlp_root_markers = ['[root]'] let g:ctrlp_open_new_file = 'h' let g:ctrlp_mruf_exclude = '' "mruに追跡したくないfile let g:ctrlp_prompt_mappings = {} "移動 let g:ctrlp_prompt_mappings['PrtCurStart()'] = [''] let g:ctrlp_prompt_mappings['PrtCurEnd()'] = [''] let g:ctrlp_prompt_mappings['PrtCurLeft()'] = ['', '', ] let g:ctrlp_prompt_mappings['PrtCurRight()'] = ['', ''] let g:ctrlp_prompt_mappings['PrtSelectMove("j")'] = ['', ''] let g:ctrlp_prompt_mappings['PrtSelectMove("k")'] = ['', ''] let g:ctrlp_prompt_mappings['PrtSelectMove("t")'] = ['', '', ] let g:ctrlp_prompt_mappings['PrtSelectMove("b")'] = ['', '', ] let g:ctrlp_prompt_mappings['PrtSelectMove("u")'] = ['', '', ] let g:ctrlp_prompt_mappings['PrtSelectMove("d")'] = ['', '', ] let g:ctrlp_prompt_mappings['PrtHistory(-1)'] = [''] let g:ctrlp_prompt_mappings['PrtHistory(1)'] = [''] "入力 let g:ctrlp_prompt_mappings['PrtBS()'] = ['', ''] let g:ctrlp_prompt_mappings['PrtDelete()'] = ['', ''] let g:ctrlp_prompt_mappings['PrtDeleteWord()'] = [''] let g:ctrlp_prompt_mappings['PrtClear()'] = [''] let g:ctrlp_prompt_mappings['PrtExpandDir()'] = [''] let g:ctrlp_prompt_mappings['PrtInsert("c")'] = ['', '', '8', '@'] let g:ctrlp_prompt_mappings['PrtInsert()'] = ['', ''] "開く let g:ctrlp_prompt_mappings['AcceptSelection("e")'] = ['', '<2-LeftMouse>', ''] let g:ctrlp_prompt_mappings['AcceptSelection("h")'] = ['s', '',] let g:ctrlp_prompt_mappings['AcceptSelection("t")'] = ['v'] let g:ctrlp_prompt_mappings['AcceptSelection("v")'] = ['b',] let g:ctrlp_prompt_mappings['CreateNewFile()'] = [''] let g:ctrlp_prompt_mappings['MarkToOpen()'] = [''] let g:ctrlp_prompt_mappings['OpenMulti()'] = [''] "トグル let g:ctrlp_prompt_mappings['ToggleRegex()'] = [''] let g:ctrlp_prompt_mappings['ToggleByFname()'] = [''] let g:ctrlp_prompt_mappings['ToggleType(1)'] = ['', ''] let g:ctrlp_prompt_mappings['ToggleType(-1)'] = ['', ''] let g:ctrlp_prompt_mappings['ToggleFocus()'] = [''] "その他 let g:ctrlp_prompt_mappings['PrtClearCache()'] = [''] let g:ctrlp_prompt_mappings['PrtDeleteEnt()'] = [''] let g:ctrlp_prompt_mappings['PrtExit()'] = ['', '', ''] "}}} "unite.vim "------------------ "unite preference "{{{ "let g:unite_enable_start_insert=1 "入力モードで開始する let g:unite_split_rule = 'botright' "窓の表示位置 let g:unite_winheight = 20 "水平分割時の窓高さ "let g:unite_quick_match_table "let g:unite_data_directory let g:unite_source_grep_command = 'jvgrep' "grepコマンド "let g:unite_source_grep_recursive_opt = '-R' "let g:unite_source_grep_default_opts = '-Hn' "let g:unite_source_find_command = 'find' let g:unite_source_history_yank_enable = 1 "unite-history/yankを有効化する(ヤンクしたテキストの履歴) "}}} aug vimrc_unite au! au FileType unite setl wfh|wincmd = "unite basic-Keymaps "{{{ let g:unite_no_default_keymappings = 1 au FileType unite nmap i (unite_insert_enter) au FileType unite nmap I (unite_insert_enter) au FileType unite nmap a \ unite#smart_map("\(unite_append_enter)", \ "\(unite_choose_action)") au FileType unite nmap A (unite_append_end) au FileType unite nmap q (unite_exit) au FileType unite imap (unite_exit) au FileType unite nmap Q (unite_all_exit) au FileType unite nmap (unite_restart) au FileType unite nmap @ (unite_toggle_mark_current_candidate) au FileType unite nmap vv (unite_toggle_mark_all_candidates) au FileType unite nmap M (unite_toggle_max_candidates) au FileType unite nmap (unite_choose_action) au FileType unite nmap (unite_rotate_next_source) au FileType unite nmap (unite_rotate_previous_source) au FileType unite nmap (unite_print_candidate) au FileType unite nmap (unite_redraw) au FileType unite nmap (unite_delete_backward_path) au FileType unite nmap gg (unite_cursor_top) au FileType unite nmap G (unite_cursor_bottom) au FileType unite nmap j (unite_loop_cursor_down) au FileType unite nmap (unite_loop_cursor_down) au FileType unite nmap k (unite_loop_cursor_up) au FileType unite nmap (unite_loop_cursor_up) au FileType unite nmap J (unite_skip_cursor_down) au FileType unite nmap K (unite_skip_cursor_up) au FileType unite nmap ? (unite_quick_help) au FileType unite nmap (unite_do_default_action) au FileType unite nmap (unite_do_default_action) au FileType unite nnoremap dd \ unite#smart_map('d', unite#do_action('delete')) au FileType unite nnoremap b \ unite#smart_map('b', unite#do_action('bookmark')) au FileType unite nnoremap e \ unite#smart_map('e', unite#do_action('edit')) au FileType unite nnoremap p \ unite#do_action('preview') au FileType unite nmap x \ unite#smart_map('x', "\(unite_quick_match_default_action)") au FileType unite nnoremap t unite#smart_map('t', unite#do_action('tabopen')) au FileType unite inoremap t unite#smart_map('t', unite#do_action('tabopen')) au FileType unite nnoremap yy unite#smart_map('yy', unite#do_action('yank')) au FileType unite xmap @ (unite_toggle_mark_selected_candidates) au FileType unite imap (unite_insert_leave) au FileType unite imap (unite_choose_action) au FileType unite imap (unite_select_next_line) au FileType unite imap (unite_select_next_line) au FileType unite imap (unite_select_previous_line) au FileType unite imap (unite_select_previous_line) au FileType unite imap (unite_select_next_page) au FileType unite imap (unite_select_previous_page) au FileType unite imap (unite_do_default_action) au FileType unite imap (unite_do_default_action) au FileType unite imap (unite_delete_backward_char) au FileType unite imap (unite_delete_backward_char) au FileType unite imap (unite_delete_backward_line) au FileType unite imap (unite_delete_backward_word) au FileType unite imap (unite_move_head) au FileType unite imap (unite_move_head) au FileType unite imap (unite_redraw) au FileType unite inoremap e \ unite#smart_map('e', unite#do_action('edit')) au FileType unite inoremap d \ unite#smart_map('d', unite#do_action('delete')) au FileType unite imap @ \ unite#smart_map('@', "\(unite_toggle_mark_current_candidate)") au FileType unite imap x \ unite#smart_map('x', "\(unite_quick_match_default_action)") "}}} "ウィンドウを分割して開く au FileType unite nnoremap unite#do_action('split') "昇降切換 au FileType unite nnoremap unite#mappings#set_current_filters( \ empty(unite#mappings#get_current_filters()) ? ['sorter_reverse'] : []) "no_quit切換 au FileType unite nnoremap :let b:unite.context.no_quit = !b:unite.context.no_quit|echo b:unite.context.no_quit aug END AlterCommand u[nite] Unite AlterCommand ua Unite -auto-preview AlterCommand una Unite -auto-preview " custom_actions for unite. (from thinca) " echo action {{{ " uniteのアクションがつまりどんなことを行うのかをプレビューする(candidateを一 " 覧する) let s:unite_action = { \ 'description': 'Echo the candidates for debug.', \ 'is_selectable': 1, \ } function! s:unite_action.func(candidates) PP a:candidates endfunction call unite#custom_action('common', 'echo', s:unite_action) unlet! s:unite_action "}}} "unite-sorce "------------------ "{{{ "unite neobundle AlterCommand nb Unite neobundle AlterCommand nbi Unite -auto-quit neobundle/install AlterCommand nbu Unite neobundle/update AlterCommand nbl Unite neobundle/log AlterCommand nbus \ Unite neobundle/install:unite.vim:vimshell:vimfiler:vimproc:neobundle:neocomplcache:neocomplcache-snippets-complete AlterCommand nbum \ Unite neobundle/install:vim-quickrun:vital.vim:open-browser.vim:vim-submode:vim-surround:CamelCaseMotion "文字関係 nnoremap ,ag :Unite -buffer-name=register register nnoremap ,ay :Unite history/yank xnoremap ,ay d:Unite history/yank inoremap pumvisible() ? "\" : "\:Unite history/yank\" "file/buf関係 nnoremap ,afl :UniteWithBufferDir -buffer-name=files file nnoremap ,aff :Unite -buffer-name=files file nnoremap ,afr :Unite -buffer-name=files -start-insert file_rec:=escape(expand('%:p:h:h'), ': ') nnoremap ,afs :UniteWithBufferDir -buffer-name=files -start-insert buffer file_mru bookmark file nnoremap ,fs :UniteWithBufferDir -buffer-name=files -start-insert buffer file_mru bookmark file nnoremap ,afm :Unite -buffer-name=files -start-insert file_mru nnoremap ,fm :Unite -buffer-name=files -start-insert file_mru nnoremap ,ap :Unite -buffer-name=files -start-insert buffer nnoremap mp :Unite -buffer-name=files -start-insert buffer nnoremap ,av :Unite -buffer-name=files buffer_tab nnoremap ,fv :Unite -buffer-name=files buffer_tab nnoremap ,aa :UniteBookmarkAdd nnoremap ,ab :Unite bookmark "nnoremap ,au :Unite buffer_deleted "場所関係 nnoremap ,al :Unite line -start-insert nnoremap ,ajc :Unite change nnoremap ,ajj :Unite jump nnoremap ,amm :Unite mark "let g:unite_source_mark_marks = '`mlkjih".^MLKJIHabcdefgnopqrstuvwxyzABCDEFGNOPQRSTUVWXYZ012' let g:unite_source_mark_marks = '`abcdefghijkl".^ABCDEFGHIJKLmnopqrstuvwxyzMNOPQRSTUVWXYZ012' nnoremap ,ai :Unite outline_indent nnoremap ,aia :Unite outline_indent:a autocmd BufEnter * \ if empty(&buftype) \| nnoremap :UniteWithCursorWord -immediately tag \| endif "vim関係 nnoremap ,amp :Unite mapping nnoremap ,ams :Unite output:mes nnoremap ,ame :Unite output:mes "GUI/CUI関係 nnoremap ,axf :Unite font nnoremap ,axw :Unite webcolorname "unite関係 nnoremap ,au :UniteResume nnoremap ,as :Unite source nnoremap ,a@ :Unite menu:main nnoremap ,a:m :Unite menu:main nnoremap ,a:g :Unite menu:git "source-buffer ファイル名に色を付ける au Syntax unite \ syntax match uniteSource__Buffer_Fname "[^/]\{-1,}\ze\s\[" \ contained containedin=uniteSource__Buffer highlight default link uniteSource__Buffer_Fname Constant "source-menu "{{{ if !exists("g:unite_source_menu_menus") let g:unite_source_menu_menus = {} endif let s:main = {} "{{{ function s:main.map(key, value) return { 'word' : a:key, 'kind' : 'command', 'action__command' : a:value } endfunction let s:main.candidates = {} "let s:main.candidates[''] = let s:main.candidates['00 menubar'] = 'Unite menu:menubar' let s:main.candidates['10 git cheatsheet'] = 'e ~/dc2/git_cheatsheet' let s:main.candidates['10 vimscripttips.vim'] = 'e ~/dc2/vimscripttips.vim' let s:main.candidates['h 41.6'] = 'h 41.6' let s:main.candidates['h functions'] = 'h functions' let s:main.candidates['h [cword]()'] = "exe'h '. g:__cursor_string()[0]. '()'" let s:main.candidates['put_vim_modeline'] = 'call g:__put_vim_modeline()' let g:unite_source_menu_menus.main = deepcopy(s:main) unlet s:main "}}} "from Mr.rbtnn function! g:__cursor_string() "{{{ " カーソル下のあるpatternにマッチするワードと始まりから終わりまでの位置をリストで返す。 " もしマッチしなければ空文字となる。 " 例えばカーソル行が「 ret*rn 9」の場合(*がカーソル位置) " :echo g:cursor_string() " pattern ==# '[a-zA-Z0-9]' " ['return',2,7] " となる。 let pattern = get(g:,'search_pattern',"[a-zA-Z0-9:#_]") let line = getline(".") let pos = getpos(".") " パターンにマッチする先頭に移動する let s = pos[2] + pos[3] - 1 while line[s] =~ pattern if s < 0 break else let s = s - 1 endif endwhile let s = s + 1 " パターンにマッチする後尾まで移動する let e = pos[2] + pos[3] - 1 while line[e] =~ pattern if e < 0 break else let e = e + 1 endif endwhile let e = e - 1 if s > e return ["",(pos[2]+pos[3]-1),(pos[2]+pos[3]-1)] else return [(line[(s):(e)]),(s),(e)] endif endfunction "}}} function! g:__put_vim_modeline() " {{{ if &commentstring =~ "%s" let cs = &commentstring else let cs = '// %s' endif let cs_str = printf(cs, join([ \ 'vim:' \ , 'set' \ , 'ft=' . &ft \ , 'fdm=' . &fdm \ , 'ff=' . &ff \ , 'fileencoding=' . &fileencoding \ , ':' \ ], " ")) if getline("$") =~ '.*vim:' call setline("$",cs_str) else call append("$",[cs_str]) endif endfunction "}}} let s:menubar = {} "{{{ function s:menubar.map(key, value) return { 'word' : a:key, 'kind' : 'command', 'action__command' : a:value } endfunction let s:menubar.candidates = {} "let s:menubar.candidates[''] = let s:menubar.candidates['01Color test'] = 'sp $VIMRUNTIME/syntax/colortest.vim|so %' let s:menubar.candidates['02Highlight test'] = 'sp |runtime syntax/hitest.vim' let s:menubar.candidates['03Convert to HTML'] = 'sp runtime syntax/2html.vim' let s:menubar.candidates['10エンコード指定して再読込(UTF-8)'] = 'e ++enc=utf-8' let s:menubar.candidates['11エンコード指定して再読込(SJIS cp932)'] = 'e ++enc=cp932' let s:menubar.candidates['12エンコード指定して再読込(EUC)'] = 'e ++enc=euc-jp' let s:menubar.candidates['13エンコード指定して再読込(JIS)'] = 'e ++enc=iso-2022-jp' let g:unite_source_menu_menus.menubar = deepcopy(s:menubar) unlet s:menubar "}}} "}}} "}}} "やたら長い変数をechoするとき見やすく表示 function! s:Unite_echo_var(args) "{{{ exe 'Unite output_in_multiline:echo\ '. escape(a:args, ': ') endfunction "}}} let s:source = { \ 'name' : 'output_in_multiline', \ 'description' : 'candidates from Vim command output', \ 'default_action' : 'yank', \ } function! s:source.gather_candidates(args, context)"{{{ if type(get(a:args, 0, '')) == type([]) " Use args directly. let result = a:args[0] else let command = join(a:args, ' ') if command == '' let command = input('Please input Vim command: ', '', 'command') endif redir => output silent! execute command redir END let result = split(output, '\r\n\|\n\|,\zs') endif return map(result, '{ \ "word" : v:val, \ "kind" : "word", \ "is_multiline" : 1, \ }') endfunction"}}} call unite#define_source(s:source) unlet s:source command! -complete=var -nargs=+ UniteEchoVar call Unite_echo_var() "-------------------------------------- "プラグイン ファイラー "netrw let g:netrw_liststyle = 3 "常にtree view "vimshell.vim"{{{ noremap ,xs :let A = expand('%:p:h')| exe 'VimShellTab '. A|unlet A au FileType vimshell setl nobl au FileType vimshell nmap (vimshell_enter) au FileType vimshell imap (vimshell_enter) au FileType vimshell nnoremap q :tabc "au FileType vimshell nmap q (vimshell_exit) "< NOTE: exitが正常化されるまでの暫定 au FileType vimshell nnoremap ,ab :Unite -default-action=cd bookmark au FileType vimshell nnoremap ,ad :Unite -default-action=cd directory_mru let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")' "ユーザプロンプトにカレントディレクトリを表示 let g:vimshell_split_height = 50 "let g:vimshell_right_prompt = 'vcs#info("(%s)-[%b]", "(%s)-[%b|%a]")' let g:vimshell_enable_smart_case = 1 if has('win32') || has('win64') " Display user name on Windows. let g:vimshell_prompt = $USERNAME."% " else " Display user name on Linux. let g:vimshell_prompt = $USER."% " call vimshell#set_execute_file('bmp,jpg,png,gif', 'gexe eog') call vimshell#set_execute_file('mp3,m4a,ogg', 'gexe amarok') let g:vimshell_execute_file_list['zip'] = 'zipinfo' call vimshell#set_execute_file('tgz,gz', 'gzcat') call vimshell#set_execute_file('tbz,bz2', 'bzcat') endif " Initialize execute file list. let g:vimshell_execute_file_list = {} call vimshell#set_execute_file('txt,vim,c,h,cpp,d,xml,java', 'vim') let g:vimshell_execute_file_list['rb'] = 'ruby' let g:vimshell_execute_file_list['pl'] = 'perl' let g:vimshell_execute_file_list['py'] = 'python' call vimshell#set_execute_file('html,xhtml', 'gexe firefox') autocmd FileType vimshell \ call vimshell#altercmd#define('g', 'git') \| call vimshell#altercmd#define('i', 'iexe') \| call vimshell#altercmd#define('l', 'll') \| call vimshell#altercmd#define('ll', 'ls -l') \| call vimshell#hook#add('chpwd', 'my_chpwd', 'g:my_chpwd') function! g:my_chpwd(args, context) call vimshell#execute('ls') endfunction autocmd FileType int-* call s:interactive_settings() function! s:interactive_settings() endfunction "}}} "vimfiler "vf preference "{{{ let g:vimfiler_as_default_explorer = 1 let g:unite_kind_file_use_trashbox = 1 let g:vimfiler_safe_mode_by_default = 0 "let g:vimfiler_split_rule = 'belowright' "let g:vimfiler_detect_drives "let g:vimfiler_data_directory "拡張子関連付け "call vimfiler#set_execute_file('vim', 'vim') "シンタックス "let g:vimfiler_extensions = { \ 'text': '', \ 'image': '', \ 'archive': '', \ 'system': '', \ 'multimedia': '', \ } "}}} "vf call mappings "nnoremap ,xf :VimFilerBufferDir -double -split -horizontal "nnoremap ,fd :VimFilerBufferDir -double -split -reverse nnoremap ,ff :VimFiler -split -horizontal -reverse nnoremap ,fj :VimFiler -split -winwidth=24 -simple -reverse -explorer =__Get_prjRoot() nnoremap ,fov :VimFiler -split -horizontal -reverse $VIMFILES nnoremap ,fr :Unite -buffer-name=files -start-insert file_rec:=escape(__Get_prjRoot(), ': ') nnoremap ,fl :VimFilerBufferDir -split -horizontal -reverse nnoremap ,fb :Unite -default-action=vimfiler bookmark nnoremap ,fd :Unite -default-action=vimfiler directory_mru "nnoremap ,xf :call vimfiler#switch_filer(join([expand('%:p:h')]), {'split': 1, 'double': 1, 'horizontal': 1}) function! s:__Get_prjRoot() "{{{ let prjRootPath = finddir('.git', expand('%:p:h').';') if empty(prjRootPath) return expand('%:p:h:h') endif return fnamemodify(prjRootPath, ':h') endfunction "}}} aug vimrc_vimfiler au! au FileType vimfiler setl nobl au FileType vimfiler let b:vimfiler.is_visible_dot_files = 1 "vf basic-Keymaps "{{{ let g:vimfiler_no_default_key_mappings = 1 au FileType vimfiler nmap j (vimfiler_loop_cursor_down) au FileType vimfiler nmap k (vimfiler_loop_cursor_up) au FileType vimfiler nmap gg (vimfiler_cursor_top) au FileType vimfiler nmap (vimfiler_redraw_screen) au FileType vimfiler nmap @ (vimfiler_toggle_mark_current_line) au FileType vimfiler nmap ` (vimfiler_toggle_mark_current_line_up) au FileType vimfiler nmap (vimfiler_switch_to_other_window) au FileType vimfiler nmap i (vimfiler_switch_to_another_vimfiler) "au FileType vimfiler nmap i :call Vimfiler_switch_to_other_window() au FileType vimfiler nmap vv (vimfiler_toggle_mark_all_lines) au FileType vimfiler nmap vu (vimfiler_clear_mark_all_lines) au FileType vimfiler nmap zc (vimfiler_copy_file) au FileType vimfiler nmap zm (vimfiler_move_file) au FileType vimfiler nmap zd (vimfiler_delete_file) au FileType vimfiler nmap r (vimfiler_rename_file) au FileType vimfiler nmap K (vimfiler_make_directory) au FileType vimfiler nmap E (vimfiler_new_file) au FileType vimfiler nmap (vimfiler_execute) au FileType vimfiler nmap (vimfiler_execute) au FileType vimfiler nmap l (vimfiler_smart_l) au FileType vimfiler nmap x (vimfiler_execute_system_associated) au FileType vimfiler nmap <2-LeftMouse> (vimfiler_execute_system_associated) au FileType vimfiler nmap h (vimfiler_smart_h) au FileType vimfiler nmap (vimfiler_switch_to_parent_directory) au FileType vimfiler nmap L (vimfiler_switch_to_drive) au FileType vimfiler nmap ~ (vimfiler_switch_to_home_directory) au FileType vimfiler nmap \ (vimfiler_switch_to_root_directory) au FileType vimfiler nmap (vimfiler_switch_to_history_directory) au FileType vimfiler nmap z. (vimfiler_toggle_visible_dot_files) au FileType vimfiler nmap H (vimfiler_popup_shell) au FileType vimfiler nmap ee (vimfiler_edit_file) "au FileType vimfiler nmap E (vimfiler_split_edit_file) au FileType vimfiler nnoremap es vimfiler#do_action('split') au FileType vimfiler nmap B (vimfiler_edit_binary_file) au FileType vimfiler nmap er (vimfiler_edit_binary_file) au FileType vimfiler nmap ge (vimfiler_execute_external_filer) au FileType vimfiler nmap (vimfiler_execute_external_filer) au FileType vimfiler nmap (vimfiler_execute_external_filer) au FileType vimfiler nmap ! (vimfiler_execute_shell_command) au FileType vimfiler nmap q (vimfiler_close) au FileType vimfiler nmap ddq (vimfiler_exit) au FileType vimfiler nmap ? (vimfiler_help) au FileType vimfiler nmap vi (vimfiler_preview_file) au FileType vimfiler nmap o (vimfiler_sync_with_current_vimfiler) au FileType vimfiler nmap O (vimfiler_open_file_in_another_vimfiler) au FileType vimfiler nmap b (vimfiler_open_file_in_another_vimfiler) au FileType vimfiler nmap (vimfiler_print_filename) au FileType vimfiler nmap g (vimfiler_toggle_maximize_window) au FileType vimfiler nmap yy (vimfiler_yank_full_path) au FileType vimfiler nmap M (vimfiler_set_current_mask) au FileType vimfiler nmap gr (vimfiler_grep) au FileType vimfiler nmap gf (vimfiler_find) au FileType vimfiler nmap S (vimfiler_select_sort_type) au FileType vimfiler nmap (vimfiler_switch_vim_buffer_mode) au FileType vimfiler nmap gc (vimfiler_cd_vim_current_dir) au FileType vimfiler nmap gs (vimfiler_toggle_safe_mode) au FileType vimfiler nmap gS (vimfiler_toggle_simple_mode) au FileType vimfiler nmap a (vimfiler_choose_action) au FileType vimfiler nmap Y (vimfiler_pushd) au FileType vimfiler nmap P (vimfiler_popd) au FileType vimfiler nmap t (vimfiler_expand_tree) au FileType vimfiler nmap . (vimfiler_expand_tree) au FileType vimfiler nmap T (vimfiler_expand_tree_recursive) au FileType vimfiler nmap I (vimfiler_cd_input_directory) au FileType vimfiler vmap @ (vimfiler_toggle_mark_selected_lines) "}}} au FileType vimfiler nnoremap eb vimfiler#do_action('vsplit') au FileType vimfiler nnoremap ev vimfiler#do_action('tabopen') au FileType vimfiler nnoremap ,ab :Unite -default-action=vimfiler bookmark au FileType vimfiler nnoremap ,ad :Unite -default-action=vimfiler directory_mru aug END function! s:Vimfiler_switch_to_other_window() "{{{ while 1 wincmd w if &ft == 'vimfiler' break endif endwhile endfunction "}}} "-------------------------------------- "プラグイン ライター "チェンジログでエントリ作成時に表示されるユーザ名 let g:changelog_username ="LC <>" "vimwiki.vimで使うwikiのリスト "let g:vimwiki_list = [{'path':'~/dc/stgmemwk/','index':'stgmemwk' },{'path':'~/dc/siicwk/','index':'siicwk' },{'path':'~/dc/yukokwk/','index':'yukokwk' },{'path':'~/dc/kywrd/','index':'kywrd' },] "----------------------------------------------------------------------------- "プラグイン ライブラリ "----------------------------------------------------------------------------- "プラグイン 環境 "neobundle ">Lazyしていたpluginsを読み込む AlterCommand nbs[ource] NeoBundleSource AlterCommand nbc NeoBundleClean command! -nargs=0 NeoBundleUpdateShougo \ NeoBundleUpdate \ unite.vim vimshell vimfiler vimproc neobundle.vim neocomplcache neocomplcache-snippets-complete command! -nargs=0 NeoBundleUpdateMain \ NeoBundleUpdate \ vim-quickrun vital.vim open-browser.vim vim-submode vim-surround CamelCaseMotion "openbrowser.vim(カーソル下のURL,URIをブラウザで開く、または単語をブラウザで検索する) nmap ,xo (openbrowser-smart-search) vmap ,xo (openbrowser-smart-search) "savevers.vimで世代別バックアップを取る"{{{ "バックアップファイルの設定" savevers.vimのためにパッチモードにします set patchmode=.vbcu "カンマで区切られたバックアップを作成するファイル名です "*.c,*.h,*.vim" let savevers_types = "*" "バックアップファイルが書き込まれるディレクトリです ここでは、オプション"backupdir"と同じディレクトリにしています let savevers_dirs = &backupdir "バックアップファイルとの比較でウィンドウのサイズを変更する場合は0 let versdiff_no_resize=1 "ウィンドウのサイズを変更する場合にどれだけの幅までを許可するか "let versdiff_no_resize=80 nmap :VersDiff - nmap :VersDiff + nmap :VersDiff -c "}}} "submode let g:submode_timeoutlen = 5000 "revolver.vim nmap mm (revolver-mark-local-typeB) nmap mM (revolver-mark-global) nmap m (revolver-mark-global) nmap mi (revolver-mark-global-typeB) exe 'nmap '. s:bind_markj. ', (revolver-jump-last-local-mark)zv' nnoremap z,m m "nmap (revolver-jump-last-local-mark)zv "let g:revolver_register_enable_logging = 2 nmap zq (revolver-register-recording) nnoremap z,q q "lastbuf let g:lastbuf_level= 2 exe 'noremap '. s:bind_win. 'u :LastBuf' "----------------------------------------------------------------------------- "プラグイン 入力 "NERDcommenter "let g:NERDCreateDefaultMappings = 0 "let g:NERDRemoveExtraSpaces = 1 "let g:NERDSpacesDelims = 0 nmap gc [cm] vmap gc [cm] nmap [cm]c NERDCommenterToggle vmap [cm]c NERDCommenterToggle nmap [cm]a NERDCommenterAppend nmap [cm]9 NERDCommenterToEOL vmap [cm]x NERDCommenterSexy vmap [cm]b NERDCommenterMinimal "altercmd (other) AlterCommand g[it] Git AlterCommand grao Git remote add origin git@github.com:LeafCage/.git AlterCommand c[tags] !start ctags % AlterCommand vit[alize] Vitalize =expand('%:p:h') AlterCommand sf setf AlterCommand so so % AlterCommand me mes "migemo.vim if has('migemo') set migemo "set migemodict=/opt/local/share/migemo/utf-8/migemo-dict endif noremap m/ :Migemo "neocomplcache.vim Preference"{{{ "let g:neocomplcache_temporary_dir = $VIM.'/settings/.neocon' "ネオコンの一時情報を書き出すディレクトリ "key:ft, value:辞書ファイルのpath > let g:neocomplcache_dictionary_filetype_lists = { \ 'default' : '', \ 'vim' : '~/.neocon_user/neocon_dict/vim.dict', \ 'vimshell' : $HOME.'/.vimshell_hist', \ 'scheme' : $HOME.'/.gosh_completions' \ } let g:neocomplcache_enable_at_startup = 1 "ネオコン有効化 let g:neocomplcache_enable_prefetch = 1 "以前のバージョンの挙動にする。 "let g:neocomplcache_disable_auto_complete = 1 "自動補完を無効にする let g:neocomplcache_enable_smart_case = 1 "スマートケィス(大文字が含まれている場合は区別する) let g:neocomplcache_enable_underbar_completion = 1 "アンダーバー_を区切りとした曖昧検索 let g:neocomplcache_enable_camel_case_completion = 1 "大文字を区切りとした曖昧検索 "let g:neocomplcache_enable_auto_select = 1 "ポップアップを出すとき自動的に一番上の候補を選択状態 let g:neocomplcache_auto_completion_start_length = 2 "ポップアップを出し始める文字数(初期値2) let g:neocomplcache_min_syntax_length = 3 "シンタックス最小キャッシュ文字数 let g:neocomplcache_min_keyword_length = 2 "補完を行うキーワードの最小長さ(初期値4) "ネオコンが未対応のファイルタイプでのキーワード収集パターン(ファイルタイプ別に指定) if !exists('g:neocomplcache_keyword_patterns') let g:neocomplcache_keyword_patterns = {} endif let g:neocomplcache_keyword_patterns['default'] = '\h\w*' "単語のヘッド\単語を構成する文字(数字やアルファベット)* "let g:neocomplcache_keyword_patterns['sfd'] = '\c\[:\%(\h\w*:\]\)\?\| &\h[[:alnum:]_:]*\| \$\h\w*\|-\h\w*=\?\| \%(\h\w*(\?\)\?\| ([^)]*)\?\| <\h[[:alnum:]_-]*>\?\| \h[[:alnum:]_:#]*\%(!\| ()\?\)\?\| `\h\w*' "}}} "neocomplcache.vim Mappings"{{{ "Vim標準の補完をネオコンに置き換える "ファイル名補完 inoremap neocomplcache#manual_filename_complete() "オムニ補完 inoremap neocomplcache#manual_omni_complete() "キーワード補完 "inoremap pumvisible() ? "\" : neocomplcache#manual_keyword_complete() "ネオコン基本操作 "候補の共通箇所まで補完する exe 'inoremap neocomplcache#complete_common_string()' "決定してポップアップを閉じる inoremap pumvisible() ? neocomplcache#close_popup() : "\" "キャンセルしてポップアップを閉じる inoremap pumvisible() ? neocomplcache#cancel_popup() : "\" "inoremap neocomplcache#cancel_popup() "inoremap eocomplcache#cancel_popup() "ネオコンによって挿入した補完を元に戻す inoremap neocomplcache#undo_completion() "ネオコン設定変更操作 "}}} "neocomplcache-snippets-complete "{{{ au FileType snippet setl nobl au BufLeave *.snip setl nobl au FileType snippet noremap q q au FileType snippet inoremap ${} let g:neocomplcache_snippets_dir = '~/.neocon_user/neocon_snippets' "スニペットプラグインディレクトリ "カーソル前の文字列がスニペットのトリガであるなら、スニペットを展開する exe 'imap neocomplcache#sources#snippets_complete#force_expandable() ? "\(neocomplcache_snippets_force_expand)" : "\(neocomplcache_snippets_force_jump)"' "nmap :call feedkeys("a\(neocomplcache_snippets_jump)") "スニペットを編集する nnoremap ,os :wincmd s| NeoComplCacheEditSnippets nnoremap ,oS :wincmd s| NeoComplCacheEditRuntimeSnippets nnoremap ,ors :wincmd s| NeoComplCacheEditRuntimeSnippets "}}} "surround.vim "{{{ let g:surround_no_mappings = 1 nmap ds Dsurround nmap cs Csurround nmap Ysurround nmap s Yssurround nmap S Ysurround$ nmap gs Ysurround nmap gss Yssurround nmap gsS Ysurround$ nmap g Ygsurround nmap gs Ygssurround nmap gS Ygsurround$ xmap s Vsurround xmap VSurround xmap g Vgsurround nmap ys Ysurround nmap yS Ygsurround nmap yss Yssurround nmap ySs Ygssurround nmap ySS Ygssurround "}}} "----------------------------------------------------------------------------- "プラグイン 移動 "posilist.vim map (poslist-prev-pos) map (poslist-next-pos) "call submode#enter_with('posl-b', 'nv', 'r', '[space]', '(poslist-prev-buf)') "call submode#enter_with('posl-b', 'nv', 'r', '[space]', '(poslist-next-buf)') "call submode#leave_with('posl-b', 'nv', '', '') "call submode#map('posl-b', 'nv', 'r', '', '(poslist-prev-buf)') "call submode#map('posl-b', 'nv', 'r', '', '(poslist-next-buf)') " ""noremap ""noremap "call submode#enter_with('C-oC-i', 'nv', '', 'z', '') "call submode#enter_with('C-oC-i', 'nv', '', 'z', '') "call submode#leave_with('C-oC-i', 'nv', '', '') "call submode#map('C-oC-i', 'nv', '', '', '') "call submode#map('C-oC-i', 'nv', '', '', '') "camelcasemotion.vimのコマンドに置き換える "前方・後方移動をキャメルケース単位にする map w CamelCaseMotion_w map b CamelCaseMotion_b map e CamelCaseMotion_e "omap e CamelCaseMotion_ie "テキストオブジェクトに対応させる omap ib CamelCaseMotion_ib vmap ib CamelCaseMotion_ib omap ie CamelCaseMotion_ie vmap ie CamelCaseMotion_ie "h1mesuke/textobj-wiw let g:textobj_wiw_no_default_key_mappings = 1 "デフォルトで用意されてるマッピングを無効に "map w (textobj-wiw-n) "map b (textobj-wiw-p) "map e (textobj-wiw-N) "< omapの時の挙動に欠陥 "map ge (textobj-wiw-P) xmap aw (textobj-wiw-a) xmap iw (textobj-wiw-i) omap aw (textobj-wiw-a) omap iw (textobj-wiw-i) "textobj-between let g:textobj_between_no_default_key_mappings = 1 xmap as (textobj-between-a) xmap is (textobj-between-i) omap as (textobj-between-a) omap is (textobj-between-i) xmap ae (textobj-between-a) xmap ie (textobj-between-i) omap ae (textobj-between-a) omap ie (textobj-between-i) call textobj#user#plugin('cword', {'-': {'*pattern*': '\k*\%#\k*', 'select': ['*',], }, }) "----------------------------------------------------------------------------- "プラグイン コマンドライン "ambicmd.vim(コマンドモードで一定のルールでコマンド補完 exe 'cnoremap ambicmd#expand("\")' "----------------------------------------------------------------------------- "プラグイン 情報表示 "buftabs.vim(ステータスラインにバッファリストを表示) let g:buftabs_only_basename=1 "バッファタブにパスを省略してファイル名のみ表示する "echodoc.vim let g:echodoc_enable_at_startup = 1 "win-shujuukankei.vim exe 'nmap '. s:bind_win. 't (win-shujuukankei-Raise)' exe 'nmap '. s:bind_win. 'z (win-shujuukankei-Lower)' au FileType vimfiler,unite,vimshell let b:shujuu_overtaker = 1 "FoldCCnavi let g:foldCCnavi_shorten = 30 "----------------------------------------------------------------------------- "プラグイン GUI操作 " quickhl.vim map ,xh (quickhl-toggle) map ,xH (quickhl-reset) "============================================================================= "未整理空間 "vim-vcs.vim "設定用辞書変数 " let g:vcs#config = {'alias':{'st':'status'},} "smartchr "autocmd FileType vim, inoremap = smartchr#one_of(' = ', ' == ', '=') "cnoremap [ smartchr#one_of('[', '\[', {'ctype': '/?'}) " diffの設定"{{{ if has('win32') || has('win64')"{{{ set diffexpr=MyDiff() function! MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let eq = '' if $VIMRUNTIME =~ ' ' if &sh =~ '\ ' . arg3 . eq endfunction endif"}}} " difforig(バッファと元ファイルでの更新を比較・変更箇所表示)を使用可能にする。 command! DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis " ファイルまたはバッファ番号を指定して差分表示。#なら裏バッファと比較 command! -nargs=? -complete=file Diff if ''=='' | browse vertical diffsplit|else| vertical diffsplit |endif " パッチコマンド set patchexpr=MyPatch() function! MyPatch() :call system($VIM."\\'.'patch -o " . v:fname_out . " " . v:fname_in . " < " . v:fname_diff) endfunction "}}} " スクラッチ " ========== "lingr用。空白削除関数。 nnoremap ,k :call Kill_blank_line() function! Kill_blank_line() let prison = line('.') let prisonend = line('$') while prison < prisonend let checkblank =getline(".") let checkblank_next =getline(line('.')+1) if checkblank =='' && checkblank_next !='' join else "call cursor(prison+1,1) normal! j endif let prison +=1 endwhile endfunction function! s:alterbuf_load() let fname = expand(':p:r') . '.hidden' if filereadable(fname) silent! exe "1split" fnameescape(fname) | silent! hide endif endfunction autocmd BufCreate *.alter call s:alterbuf_load() "autocmd CursorMoved * redraw function! Scouter(file, ...) let pat = '^\s*$\|^\s*"' let lines = readfile(a:file) if !a:0 || !a:1 let lines = split(substitute(join(lines, "\n"), '\n\s*\\', '', 'g'), "\n") endif return len(filter(lines,'v:val !~ pat')) endfunction command! -bar -bang -nargs=? -complete=file Scouter \ echo Scouter(empty() ? $MYVIMRC : expand(), 0) unlet s:bind_win s:bind_comp s:bind_snip s:bind_markj s:bind_reg "----------------------------------------------------------------------------- "終了時エラー確認 set verbosefile=/tmp/vim.log "============================================================================= "TODO " "vimfilerにハードリンク(2000~XP)などを作らせるコマンド用意 " " "Idea etc " "カーソル位置から前後数行を対象にコマンドを実行する(画面から見える位置に限定して) "自動で関数の始まりから終わりまでが見える大きさにウィンドウサイズ変更 "コメント接頭辞にで属性変更 ] c] a] "前回の保存からの変更点をhlさせる "ステータスラインの色を変更し、そのウィンドウが別の文脈にあることを示す "hatenaようsyntax "twitterクライアントとか各種掲示板ビューア・lingrビューア "アンド検索(一件目がhitした後二件目のwordで一件目の前後数行を検索 " "----------------------------------------------------------------------------- "次の空白文字へ "レインボーブランケットをsyntaxにインポート "マーキングコメント。"[削] とか"★とかを付け外しする(ノーマルコメント←→特殊コメント) "折り畳み先頭行のシンタックスを目立たせる " "-------------------------------------- " expander " コマンドラインからzencodingっぽく 暗号+修飾したいもので修飾済みの文字列挿入 " "vimのexコマンド補完を利用したバッファセレクタやmruセレクタ、yank履歴セレクタの作成 "input()式バッファセレクタ(input()方式は汎用性があるからオブジェクトで作る?) "テスト用不思議変数g:tess01 g:tess02 "通常の変数の機能+変異を記録 "unite より使いやすいカラー一覧 "u]コマンドライン型unite "uniteをメモ帳・todoリストとして使う。要素の追加・削除がその場で行える "uniteチートシート.同上。 "長い辞書変数を適当に改行した後uniteで閲覧できるようにする