"--------------------------------------------------------------------------- " Shougo's .vimrc "--------------------------------------------------------------------------- " Initialize:"{{{ " " Enable no Vi compatible commands. set nocompatible let s:is_windows = has('win16') || has('win32') || has('win64') let s:is_cygwin = has('win32unix') let s:is_mac = !s:is_windows && !s:is_cygwin \ && (has('mac') || has('macunix') || has('gui_macvim') || \ (!executable('xdg-open') && \ system('uname') =~? '^darwin')) " Use English interface. if s:is_windows " For Windows. language message en else " For Linux. language mes C endif " Use ',' instead of '\'. " It is not mapped with respect well unless I set it before setting for plug in. let mapleader = ',' " Use in global plugin. let g:mapleader = ',' " Use in filetype plugin. let g:maplocalleader = 'm' " Release keymappings for plug-in. nnoremap ; xnoremap ; nnoremap m xnoremap m nnoremap , xnoremap , if s:is_windows " Exchange path separator. set shellslash endif " In Windows/Linux, take in a difference of ".vim" and "$VIM/vimfiles". let $DOTVIM = expand('~/.vim') " Because a value is not set in $MYGVIMRC with the console, set it. if !exists($MYGVIMRC) let $MYGVIMRC = expand('~/.gvimrc') endif " Anywhere SID. function! s:SID_PREFIX() return matchstr(expand(''), '\d\+_\zeSID_PREFIX$') endfunction function! s:set_default(var, val) if !exists(a:var) || type({a:var}) != type(a:val) let {a:var} = a:val endif endfunction " Set augroup. augroup MyAutoCmd autocmd! augroup END if filereadable(expand('~/.secret_vimrc')) execute 'source' expand('~/.secret_vimrc') endif if has('vim_starting') "{{{ " Set runtimepath. if s:is_windows let &runtimepath = join([ \ expand('~/.vim'), \ expand('$VIM/runtime'), \ expand('~/.vim/after')], ',') endif " Load neobundle. if finddir('neobundle.vim', '.;') != '' execute 'set runtimepath+=' . finddir('neobundle.vim', '.;') elseif &runtimepath !~ '/neobundle.vim' execute 'set runtimepath+=' . expand('~/.bundle/neobundle.vim') endif if findfile('vimrc_local.vim', '.;') != '' " Load develop version. call neobundle#local(fnamemodify( \ findfile('vimrc_local.vim', '.;'), ':h'), { 'resettable' : 0 }) endif endif "}}} let g:neobundle#enable_tail_path = 1 let g:neobundle#default_options = { \ 'same' : { 'stay_same' : 1, 'overwrite' : 0 }, \ '_' : { 'overwrite' : 0 }, \ } call neobundle#rc(expand('~/.bundle')) " neobundle.vim"{{{ NeoBundleFetch 'Shougo/neobundle.vim' NeoBundleLazy 'tpope/vim-surround', '', 'same' NeoBundleLazy 't9md/vim-surround_custom_mapping', '', 'same', { \ 'depends' : 'vim-surround', \ 'autoload' : { \ 'mappings' : [ \ ['n', 'Dsurround'], ['n', 'Csurround'], \ ['n', 'Ysurround'], ['n', 'YSurround'] \ ]}} NeoBundleLazy 'basyura/TweetVim', { 'depends' : \ ['basyura/twibill.vim', 'tyru/open-browser.vim'], \ 'autoload' : { 'commands' : 'TweetVimHomeTimeline' }} " \ ['basyura/twibill.vim', 'tyru/open-browser.vim', 'yomi322/neco-tweetvim'] } " NeoBundleLazy 'c9s/perlomni.vim' NeoBundleLazy 'choplin/unite-vim_hacks', '', 'same' NeoBundleLazy 'liquidz/vimfiler-sendto', '', 'same' NeoBundle 'Shougo/echodoc', '', 'same' call neobundle#config('echodoc', { \ 'lazy' : 1, \ 'autoload' : { \ 'insert' : 1, \ }}) NeoBundle 'Shougo/neocomplcache' call neobundle#config('neocomplcache', { \ 'lazy' : 1, \ 'autoload' : { \ 'insert' : 1, \ }}) NeoBundle 'Shougo/neosnippet' call neobundle#config('neosnippet', { \ 'lazy' : 1, \ 'autoload' : { \ 'insert' : 1, \ 'filetypes' : 'snippet', \ }}) " NeoBundle 'git@github.com:Shougo/neocomplcache-snippets-complete.git' NeoBundle 'Shougo/neobundle-vim-scripts' NeoBundle 'Shougo/unite.vim', call neobundle#config('unite.vim',{ \ 'lazy' : 1, \ 'autoload' : { \ 'commands' : [{ 'name' : 'Unite', \ 'complete' : 'customlist,unite#complete_source'}, \ 'UniteWithCursorWord', 'UniteWithInput'] \ }}) NeoBundle 'Shougo/unite-build' NeoBundle 'Shougo/unite-ssh' NeoBundleLazy 'ujihisa/vimshell-ssh', { 'autoload' : { \ 'filetypes' : 'vimshell', \ }} NeoBundle 'Shougo/unite-sudo' NeoBundleLazy 'Shougo/vim-vcs', { \ 'depends' : 'thinca/vim-openbuf', \ 'autoload' : {'commands' : 'Vcs'}, \ } NeoBundle 'Shougo/vimfiler' call neobundle#config('vimfiler', { \ 'lazy' : 1, \ 'depends' : 'Shougo/unite.vim', \ 'autoload' : { \ 'commands' : [{ 'name' : 'VimFiler', \ 'complete' : 'customlist,vimfiler#complete' }, \ 'VimFilerExplorer', \ 'Edit', 'Read', 'Source', 'Write'], \ 'mappings' : ['(vimfiler_switch)'] \ } \ }) " NeoBundle 'Shougo/vimfiler', 'ver.1.50' NeoBundle 'Shougo/vimproc', { \ 'build' : { \ 'windows' : 'make -f make_mingw32.mak', \ 'cygwin' : 'make -f make_cygwin.mak', \ 'mac' : 'make -f make_mac.mak', \ 'unix' : 'make -f make_unix.mak', \ }, \ } " NeoBundleLazy 'Shougo/vim-ft-vim_fold', '', 'same', " \ { 'autoload' : { 'filetypes' : 'vim' }} NeoBundle 'Shougo/vimshell' call neobundle#config('vimshell', { \ 'lazy' : 1, \ 'autoload' : { \ 'commands' : [{ 'name' : 'VimShell', \ 'complete' : 'customlist,vimshell#complete'}, \ 'VimShellExecute', 'VimShellInteractive', \ 'VimShellTerminal', 'VimShellPop'], \ 'mappings' : ['(vimshell_switch)'] \ }}) NeoBundleLazy 'yomi322/vim-gitcomplete', { 'autoload' : { \ 'filetype' : 'vimshell' \ }} NeoBundle 'Shougo/vinarise', call neobundle#config('vinarise', { \ 'lazy' : 1, \ 'autoload' : { \ 'commands' : 'Vinarise', \ }}) NeoBundle 'Shougo/vesting' call neobundle#config('vesting', { \ 'lazy' : 1, \ 'autoload' : { \ 'commands' : 'Unite', \ }}) NeoBundle 'vim-jp/vital.vim' call neobundle#config('vital.vim', { \ 'lazy' : 1, \ 'autoload' : { \ 'commands' : ['Vitalize'], \ }}) NeoBundle 'hrsh7th/vim-versions' call neobundle#config('hrsh7th/vim-versions', { \ 'lazy' : 1, \ 'autoload' : { \ 'commands' : 'UniteVersions'}, \ }) " NeoBundle 'h1mesuke/unite-outline' NeoBundle 'Shougo/unite-outline', '', 'same' NeoBundleLazy 'hail2u/vim-css3-syntax', '', 'same' NeoBundleLazy 'kana/vim-smartchr', '', 'same', { 'autoload' : { \ 'insert' : 1, \ }} NeoBundleLazy 'kana/vim-smartword', '', 'same', { 'autoload' : { \ 'mappings' : [ \ '(smartword-w)', '(smartword-b)', '(smartword-ge)'] \ }} NeoBundleLazy 'kana/vim-smarttill', '', 'same', { 'autoload' : { \ 'mappings' : [ \ '(smarttill-t)', '(smarttill-T)'] \ }} NeoBundleLazy 'kana/vim-fakeclip', '', 'same', { 'autoload' : { \ 'mappings' : [ \ ['nv', '(fakeclip-y)'], ['nv', '(fakeclip-Y)'], \ ['nv', '(fakeclip-p)'], ['nv', '(fakeclip-P)'], \ ['nv', '(fakeclip-gp)']] \ }} NeoBundleLazy 'kana/vim-operator-user', '', 'same' NeoBundleLazy 'kana/vim-operator-replace', '', 'same', { \ 'depends' : 'vim-operator-user', \ 'autoload' : { \ 'mappings' : [ \ ['nx', '(operator-replace)']] \ }} NeoBundleLazy 'kana/vim-textobj-user', '', 'same' " NeoBundleLazy 'kana/vim-wwwsearch' NeoBundleLazy 'kien/ctrlp.vim' NeoBundleLazy 'Shougo/foldCC', '', 'same', \ { 'autoload' : { 'filetypes' : 'vim' }} NeoBundleLazy 'mattn/wwwrenderer-vim', '', 'same' NeoBundle 'mattn/webapi-vim' " NeoBundle 'basyura/webapi-vim' " NeoBundle 'pocket7878/presen-vim', " \ { 'depends' : 'pocket7878/curses-vim'} NeoBundleLazy 'rson/vim-conque', '', 'same', { 'autoload' : { \ 'commands' : 'ConqueTerm' \ }} NeoBundleLazy 'sjl/gundo.vim', '', 'same', { 'autoload' : { \ 'commands' : 'GundoToggle' \ }} " NeoBundle 't9md/vim-textmanip', '', 'same' " NeoBundle 't9md/vim-quickhl', '', 'same' NeoBundleLazy 'thinca/vim-fontzoom', '', 'same', { \ 'gui' : 1, \ 'autoload' : { \ 'mappings' : [ \ ['n', '(fontzoom-larger)'], \ ['n', '(fontzoom-smaller)']] \ }} NeoBundle 'ujihisa/unite-font', '', 'same', { \ 'gui' : 1, \ } NeoBundleLazy 'thinca/vim-prettyprint', '', 'same', { 'autoload' : { \ 'commands' : 'PP' \ }} NeoBundleLazy 'thinca/vim-qfreplace', '', 'same', { 'autoload' : { \ 'filetypes' : ['unite', 'quickfix'], \ }} NeoBundleLazy 'thinca/vim-quickrun', { 'autoload' : { \ 'mappings' : [ \ ['nxo', '(quickrun)']], \ }} NeoBundleLazy 'thinca/vim-scouter', '', 'same', { 'autoload' : { \ 'commands' : 'Scouter' \ }} NeoBundleLazy 'thinca/vim-ref', { 'autoload' : { \ 'commands' : 'Ref' \ }} NeoBundle 'thinca/vim-unite-history', '', 'same' NeoBundleLazy 'vim-ruby/vim-ruby', { 'autoload' : { \ 'mappings' : '(ref-keyword)', \ 'filetypes' : 'ruby' \ }} NeoBundleLazy 'tsukkee/lingr-vim', '', 'same', { 'autoload' : { \ 'commands' : 'LingrLaunch' \ }} if has('gui_running') && !s:is_windows NeoBundleDisable lingr-vim endif NeoBundle 'Shougo/unite-help', '', 'same' NeoBundle 'tsukkee/unite-tag', '', 'same' NeoBundleLazy 'tyru/caw.vim', { 'autoload' : { \ 'mappings' : [ \ '(caw:prefix)', '(caw:i:toggle)'] \ }} NeoBundleLazy 'tyru/eskk.vim', { 'autoload' : { \ 'mappings' : [['i', '(eskk:toggle)']], \ }} NeoBundleLazy 'tyru/open-browser.vim', '', 'same', { 'autoload' : { \ 'mappings' : '(open-browser-wwwsearch)', \ }} NeoBundleLazy 'tyru/operator-html-escape.vim', '', 'same' NeoBundleLazy 'tyru/restart.vim', '', 'same', { \ 'gui' : 1, \ 'autoload' : { \ 'commands' : 'Restart' \ }} " NeoBundle 'tyru/skk.vim' NeoBundleLazy 'tyru/vim-altercmd', '', 'same' NeoBundleLazy 'tyru/winmove.vim', '', 'same', { 'autoload' : { \ 'gui' : 1, \ 'mappings' : [ \ ['n', '(winmove-up)'], ['n', '(winmove-down)'], \ ['n', '(winmove-left)'] , ['n', '(winmove-right)']], \ }} NeoBundleLazy 'ujihisa/neco-ghc', { 'autoload' : { \ 'filetypes' : 'haskell' \ }} NeoBundle 'ujihisa/neco-look', '', 'same' NeoBundleLazy 'ujihisa/unite-colorscheme', '', 'same' NeoBundleLazy 'ujihisa/unite-locate', '', 'same' NeoBundleLazy 'ujihisa/vimshell-ssh' NeoBundle 'vim-jp/vimdoc-ja.git' " NeoBundleLazy 'vim-scripts/netrw.vim', '', 'same', { 'autoload' : { " \ 'commands' : 'Explore', " \ }} " NeoBundleLazy 'Markdown', '', 'same' NeoBundleLazy 'yuratomo/w3m.vim', '', 'same', { 'autoload' : { \ 'commands' : 'W3m', \ }} NeoBundle 'pasela/unite-webcolorname', '', 'same' " NeoBundle 'hrsh7th/vim-unite-vcs', '', 'same' NeoBundle 'deris/vim-loadafterft', '', 'same' NeoBundle 'osyo-manga/unite-quickfix', '', 'same' NeoBundle 'osyo-manga/unite-filetype', '', 'same' "NeoBundle 'taglist.vim', '', 'same' NeoBundleLazy 'rbtnn/hexript.vim' NeoBundleLazy 'tpope/vim-endwise', '', 'same' NeoBundleLazy 'Rip-Rip/clang_complete', { \ 'autoload' : { \ 'filetypes' : ['c', 'cpp'], \ }, \ } NeoBundleLazy 'kana/vim-tabpagecd', '', 'same' NeoBundleLazy 'rhysd/accelerated-jk', { 'autoload' : { \ 'mappings' : ['(accelerated_jk_gj)', \ '(accelerated_jk_gk)'], \ }} " NeoBundle 'gmarik/vundle' NeoBundleLazy 'davidhalter/jedi-vim', { \ 'autoload' : { \ 'filetypes' : ['python', 'python3'], \ }, \ } NeoBundleLazy 'vim-jp/autofmt', '', 'same', { 'autoload' : { \ 'mappings' : [['x', 'gq']], \ }} " From vim.org NeoBundleLazy 'godlygeek/csapprox', '', 'same', { 'terminal' : 1 } NeoBundleLazy 'thinca/vim-guicolorscheme', '', 'same', { 'terminal' : 1 } NeoBundleLazy 'repeat.vim', '', 'same', { 'autoload' : { \ 'mappings' : '.', \ }} NeoBundleLazy 'autodate.vim', '', 'same', { 'autoload' : { \ 'filetypes' : 'vim', \ }} NeoBundleLazy 'matchit.zip', '', 'same', { 'autoload' : { \ 'mappings' : '%', \ }} " NeoBundle 'perl-mauke.vim', '', 'same' NeoBundleLazy 'DirDiff.vim', '', 'same', { 'autoload' : { \ 'commands' : 'DirDiff' \ }} NeoBundleLazy 'rhysd/clever-f.vim', { 'autoload' : { \ 'mappings' : 'f', \ }} NeoBundleLazy 'rhysd/clever-f.vim', { 'autoload' : { \ 'mappings' : 'f', \ }} NeoBundleLazy 'jiangmiao/simple-javascript-indenter', { 'autoload' : { \ 'filetypes' : 'javascript', \ }} NeoBundleLazy 'jelera/vim-javascript-syntax', { 'autoload' : { \ 'filetypes' : 'javascript', \ }} NeoBundleLazy 'bkad/CamelCaseMotion', { 'autoload' : { \ 'mappings' : ['CamelCaseMotion_w', \ 'CamelCaseMotion_b'], \ }} NeoBundleLazy 'HybridText', { 'autoload' : { \ 'filetypes' : 'hybrid', \ }} NeoBundleLocal ~/.vim/bundle " NeoBundle 'taichouchou2/alpaca_complete.git' " NeoBundle 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim', " \ {'script_type' : 'plugin'} " NeoBundle 'taichouchou2/vim-rsense' " Test. " NeoBundleLazy 'tpope/vim-fugitive' " NeoBundleLazy 'masudaK/vim-python' " NeoBundleLazy 'klen/python-mode' "}}} " Disable menu.vim if has('gui_running') set guioptions=Mc endif " Disable GetLatestVimPlugin.vim let g:loaded_getscriptPlugin = 1 " Disable netrw.vim let g:loaded_netrwPlugin = 1 filetype plugin indent on " Enable syntax color. syntax enable " Installation check. NeoBundleCheck "}}} "--------------------------------------------------------------------------- " Encoding:"{{{ " " The automatic recognition of the character code. " Setting of the encoding to use for a save and reading. " Make it normal in UTF-8 in Unix. set encoding=utf-8 " Setting of terminal encoding."{{{ if !has('gui_running') if &term == 'win32' || &term == 'win64' " Setting when use the non-GUI Japanese console. " Garbled unless set this. set termencoding=cp932 " Japanese input changes itself unless set this. " Be careful because the automatic recognition of the character code is not possible! set encoding=japan else if $ENV_ACCESS ==# 'linux' set termencoding=euc-jp elseif $ENV_ACCESS ==# 'colinux' set termencoding=utf-8 else " fallback set termencoding= " same as 'encoding' endif endif elseif s:is_windows " For system. set termencoding=cp932 endif "}}} " The automatic recognition of the character code."{{{ if !exists('did_encoding_settings') && has('iconv') let s:enc_euc = 'euc-jp' let s:enc_jis = 'iso-2022-jp' " Does iconv support JIS X 0213? if iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb" let s:enc_euc = 'euc-jisx0213,euc-jp' let s:enc_jis = 'iso-2022-jp-3' endif " Build encodings. let &fileencodings = 'ucs-bom' if &encoding !=# 'utf-8' let &fileencodings = &fileencodings . ',' . 'ucs-2le' let &fileencodings = &fileencodings . ',' . 'ucs-2' endif let &fileencodings = &fileencodings . ',' . s:enc_jis if &encoding ==# 'utf-8' let &fileencodings = &fileencodings . ',' . s:enc_euc let &fileencodings = &fileencodings . ',' . 'cp932' elseif &encoding =~# '^euc-\%(jp\|jisx0213\)$' let &encoding = s:enc_euc let &fileencodings = &fileencodings . ',' . 'utf-8' let &fileencodings = &fileencodings . ',' . 'cp932' else " cp932 let &fileencodings = &fileencodings . ',' . 'utf-8' let &fileencodings = &fileencodings . ',' . s:enc_euc endif let &fileencodings = &fileencodings . ',' . &encoding unlet s:enc_euc unlet s:enc_jis let did_encoding_settings = 1 endif "}}} if has('kaoriya') " For Kaoriya only. "set fileencodings=guess endif " When do not include Japanese, use encoding for fileencoding. function! AU_ReCheck_FENC() "{{{ if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0 let &fileencoding=&encoding endif endfunction"}}} autocmd MyAutoCmd BufReadPost * call AU_ReCheck_FENC() " Default fileformat. set fileformat=unix " Automatic recognition of a new line cord. set fileformats=unix,dos,mac " A fullwidth character is displayed in vim properly. set ambiwidth=double " Command group opening with a specific character code again."{{{ " In particular effective when I am garbled in a terminal. " Open in UTF-8 again. command! -bang -bar -complete=file -nargs=? Utf8 edit ++enc=utf-8 " Open in iso-2022-jp again. command! -bang -bar -complete=file -nargs=? Iso2022jp edit ++enc=iso-2022-jp " Open in Shift_JIS again. command! -bang -bar -complete=file -nargs=? Cp932 edit ++enc=cp932 " Open in EUC-jp again. command! -bang -bar -complete=file -nargs=? Euc edit ++enc=euc-jp " Open in UTF-16 again. command! -bang -bar -complete=file -nargs=? Utf16 edit ++enc=ucs-2le " Open in UTF-16BE again. command! -bang -bar -complete=file -nargs=? Utf16be edit ++enc=ucs-2 " Aliases. command! -bang -bar -complete=file -nargs=? Jis Iso2022jp command! -bang -bar -complete=file -nargs=? Sjis Cp932 command! -bang -bar -complete=file -nargs=? Unicode Utf16 "}}} " Tried to make a file note version."{{{ " Don't save it because dangerous. command! WUtf8 setlocal fenc=utf-8 command! WIso2022jp setlocal fenc=iso-2022-jp command! WCp932 setlocal fenc=cp932 command! WEuc setlocal fenc=euc-jp command! WUtf16 setlocal fenc=ucs-2le command! WUtf16be setlocal fenc=ucs-2 " Aliases. command! WJis WIso2022jp command! WSjis WCp932 command! WUnicode WUtf16 "}}} " Appoint a line feed."{{{ command! -bang -complete=file -nargs=? WUnix write ++fileformat=unix | edit command! -bang -complete=file -nargs=? WDos write ++fileformat=dos | edit command! -bang -complete=file -nargs=? WMac write ++fileformat=mac | edit "}}} if has('multi_byte_ime') set iminsert=0 imsearch=0 endif "}}} "--------------------------------------------------------------------------- " Search:"{{{ " " Ignore the case of normal letters. set ignorecase " If the search pattern contains upper case characters, override ignorecase option. set smartcase " Enable incremental search. set incsearch " Don't highlight search result. set nohlsearch " Searches wrap around the end of the file. set wrapscan "}}} "--------------------------------------------------------------------------- " Edit:"{{{ " " Smart insert tab setting. set smarttab " Exchange tab to spaces. set expandtab " Substitute with blanks. "set tabstop=8 " Spaces instead . "set softtabstop=4 " Autoindent width. "set shiftwidth=4 " Round indent by shiftwidth. set shiftround " Enable modeline. set modeline " Use clipboard register. if has('unnamedplus') set clipboard& clipboard+=unnamedplus else set clipboard& clipboard+=unnamed endif " Disable auto wrap. autocmd MyAutoCmd FileType * \ if &l:textwidth != 70 && &filetype !=# 'help' | \ setlocal textwidth=0 | \ endif " Enable backspace delete indent and newline. set backspace=indent,eol,start " Highlight parenthesis. set showmatch " Highlight when CursorMoved. set cpoptions-=m set matchtime=3 " Highlight <>. set matchpairs+=<:> " Display another buffer when current buffer isn't saved. set hidden " Auto reload if file is changed. "set autoread " Ignore case on insert completion. set infercase " Search home directory path on cd. " But can't complete. " set cdpath+=~ " Enable folding. set foldenable " set foldmethod=expr set foldmethod=marker " Show folding level. set foldcolumn=3 set foldcolumn=3 set fillchars=vert:\| set commentstring=%s if exists('*FoldCCtext') " Use FoldCCtext(). set foldtext=FoldCCtext() autocmd MyAutoCmd FileType * \ if &filetype !=# 'help' \ | setlocal foldtext=FoldCCtext() \ | endif endif " Use vimgrep. "set grepprg=internal " Use grep. set grepprg=grep\ -nH " Exclude = from isfilename. set isfname-== " Reload .vimrc and .gvimrc automatically. if !has('gui_running') && !s:is_windows autocmd MyAutoCmd BufWritePost .vimrc nested source $MYVIMRC | \ call s:set_syntax_of_user_defined_commands() | \ echo "source $MYVIMRC" else autocmd MyAutoCmd BufWritePost .vimrc source $MYVIMRC | \ call s:set_syntax_of_user_defined_commands() | \ if has('gui_running') | source $MYGVIMRC | echo "source $MYVIMRC" autocmd MyAutoCmd BufWritePost .gvimrc \ if has('gui_running') | source $MYGVIMRC | echo "source $MYGVIMRC" endif " Keymapping timeout. set timeout timeoutlen=3000 ttimeoutlen=100 " CursorHold time. set updatetime=1000 " Set swap directory. set directory-=. if v:version >= 703 " Set undofile. set undofile let &undodir=&directory endif " Set tags file. " Don't search tags file in current directory. And search upward. set tags& tags-=tags tags+=./tags; if v:version < 7.3 || (v:version == 7.3 && !has('patch336')) " Vim's bug. set notagbsearch endif " Enable virtualedit in visual block mode. set virtualedit=block " Set keyword help. set keywordprg=:help " Check timestamp more for 'autoread'. autocmd MyAutoCmd WinEnter * checktime " Disable paste. autocmd MyAutoCmd InsertLeave * \ if &paste | set nopaste | echo 'nopaste' | endif " Use autofmt. set formatexpr=autofmt#japanese#formatexpr() "}}} "--------------------------------------------------------------------------- " View:"{{{ " " Show line number. "set number " Show and set list if s:is_windows set listchars=tab:>-,trail:-,extends:>,precedes:< else set listchars=tab:▸\ ,trail:-,extends:»,precedes:«,nbsp:% endif " Do not wrap long line. set nowrap " Wrap conditions. set whichwrap+=h,l,<,>,[,],b,s,~ " Always display statusline. set laststatus=2 " Height of command line. set cmdheight=2 " Show command on statusline. set showcmd " Show title. set title " Title length. set titlelen=95 " Title string. let &titlestring="%{(&filetype ==# 'lingr-messages' && lingr#unread_count() > 0 )?" \ . " '('.lingr#unread_count().')' : ''}%{expand('%:p:.:~')}%(%m%r%w%)" \ . " \ %<\(%{SnipMid(fnamemodify(&filetype ==# 'vimfiler' ?" \ . "substitute(b:vimfiler.current_dir, '.\\zs/$', '', '') : getcwd(), ':~')," \ . "80-len(expand('%:p:.')),'...')}\) - VIM" " Set tabline. function! s:my_tabline() "{{{ let s = '' for i in range(1, tabpagenr('$')) let bufnrs = tabpagebuflist(i) let bufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears let no = (i <= 10 ? i : '#') " display 0-origin tabpagenr. let mod = getbufvar(bufnr, '&modified') ? '!' : ' ' " Use gettabvar(). let title = exists('*gettabvar') && gettabvar(i, 'title') != '' ? \ gettabvar(i, 'title') : fnamemodify(bufname(bufnr), ':t') let title = '[' . title . ']' let s .= '%'.i.'T' let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#' let s .= no . ':' . title let s .= mod let s .= '%#TabLineFill# ' endfor let s .= '%#TabLineFill#%T%=%#TabLine#' return s endfunction "}}} let &tabline = '%!'. s:SID_PREFIX() . 'my_tabline()' set showtabline=2 " Set statusline. let &statusline="%{winnr('$')>1?'['.winnr().'/'.winnr('$')" \ . ".(winnr('#')==winnr()?'#':'').']':''}\ " \ . "%{expand('%:p:.')}" \ . "%{".s:SID_PREFIX()."get_twitter_len()}" \ . "\ %=%m%y%{'['.(&fenc!=''?&fenc:&enc).','.&ff.']'}" \ . "%{printf(' %5d/%d',line('.'),line('$'))}" function! s:get_twitter_len() return &filetype !=# 'int-earthquake' || mode() !=# 'i' ? '' : \ '(rest:' . (140 - len(substitute(vimshell#get_cur_text(),'.','x','g'))) . ')' endfunction " Turn down a long line appointed in 'breakat' set linebreak set showbreak=>\ set breakat=\ \ ;:,!? " Do not display greetings message at the time of Vim start. set shortmess=aTI " Don't create backup. set nowritebackup set nobackup set backupdir-=. " Disable bell. set t_vb= set novisualbell " Display candidate supplement. set nowildmenu set wildmode=list:longest,full " Increase history amount. set history=200 " Display all the information of the tag by the supplement of the Insert mode. set showfulltag " Can supplement a tag in a command-line. set wildoptions=tagfile " Enable spell check. set spelllang=en_us " Completion setting. set completeopt=menuone " Don't complete from other buffer. set complete=. "set complete=.,w,b,i,t " Set popup menu max height. set pumheight=20 " Report changes. set report=0 " Maintain a current line at the time of movement as much as possible. set nostartofline " Splitting a window will put the new window below the current one. set splitbelow " Splitting a window will put the new window right the current one. set splitright " Set minimal width for current window. set winwidth=30 " Set minimal height for current window. " set winheight=20 set winheight=1 " Set maximam maximam command line window. set cmdwinheight=5 " No equal window size. set noequalalways " Adjust window size of preview and help. set previewheight=10 set helpheight=12 " Don't redraw while macro executing. set lazyredraw " When a line is long, do not omit it in @. set display=lastline " Display an invisible letter with hex format. "set display+=uhex " Disable automatically insert comment. autocmd MyAutoCmd FileType * setl formatoptions-=ro | setl formatoptions+=mM let g:execcmd_after_ftplugin = { \ '_': [ \ 'setlocal fo-=t fo-=c fo-=r fo-=o', \ ], \ 'c': [ \ 'setlocal fo-=t fo-=c fo-=r fo-=o', \ ], \ 'perl': [ \ 'setlocal fo-=t fo-=c fo-=r fo-=o', \ ], \} let g:execcmd_after_indent = { \ '_': [ \ 'setlocal fo-=t fo-=c fo-=r fo-=o', \ ], \ 'php': [ \ 'setlocal fo-=t fo-=c fo-=r fo-=o', \ ], \} if v:version >= 703 " For conceal. set conceallevel=2 concealcursor=iv set colorcolumn=85 endif " View setting. set viewdir=~/.vim/view viewoptions-=options viewoptions+=slash,unix "}}} "--------------------------------------------------------------------------- " Syntax:"{{{ " " Enable smart indent. set autoindent smartindent augroup MyAutoCmd " Enable gauche syntax. autocmd FileType scheme nested let b:is_gauche=1 | setlocal lispwords=define | \let b:current_syntax='' | syntax enable " Auto reload VimScript. autocmd BufWritePost,FileWritePost *.vim if &autoread \ | source | echo 'source ' . bufname('%') | endif " Manage long Rakefile easily autocmd BufNewfile,BufRead Rakefile foldmethod=syntax foldnestmax=1 " Close help and git window by pressing q. autocmd FileType help,git-status,git-log,qf, \gitcommit,quickrun,qfreplace,ref, \simpletap-summary,vcs-commit,vcs-status,vim-hacks \ nnoremap q :call smart_close() autocmd FileType * if (&readonly || !&modifiable) && !hasmapto('q', 'n') \ | nnoremap q :call smart_close()| endif autocmd FileType gitcommit setlocal nofoldenable " Close help and git window by pressing q. autocmd FileType ref nnoremap w " Enable omni completion. " autocmd FileType ada setlocal omnifunc=adacomplete#Complete " autocmd FileType c setlocal omnifunc=ccomplete#Complete autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags "autocmd FileType java setlocal omnifunc=javacomplete#Complete " autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS " autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP " autocmd FileType python setlocal omnifunc=pythoncomplete#Complete "autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete "autocmd FileType sql setlocal omnifunc=sqlcomplete#Complete autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags autocmd FileType python setlocal foldmethod=indent " Update filetype. autocmd BufWritePost * \ if &l:filetype ==# '' || exists('b:ftdetect') \ | unlet! b:ftdetect \ | filetype detect \ | endif autocmd BufEnter,BufNewFile * if bufname('%') != '' && &filetype == '' \ | setlocal ft=hybrid | endif augroup END " Java let g:java_highlight_functions = 'style' let g:java_highlight_all = 1 let g:java_allow_cpp_keywords = 1 " PHP let g:php_folding = 1 " Python let g:python_highlight_all = 1 " XML let g:xml_syntax_folding = 1 " Vim let g:vimsyntax_noerror = 1 "let g:vim_indent_cont = 0 " Bash let g:is_bash = 1 " Java let g:java_highlight_all=1 let g:java_highlight_debug=1 let g:java_allow_cpp_keywords=1 let g:java_space_errors=1 let g:java_highlight_functions=1 " JavaScript let g:SimpleJsIndenter_BriefMode = 1 let g:SimpleJsIndenter_CaseIndentLevel = -1 " Syntax highlight for user commands. augroup syntax-highlight-extends autocmd! autocmd Syntax vim \ call s:set_syntax_of_user_defined_commands() augroup END function! s:set_syntax_of_user_defined_commands() redir => _ silent! command redir END let command_names = join(map(split(_, '\n')[1:], \ "matchstr(v:val, '[!\"b]*\\s\\+\\zs\\u\\w*\\ze')")) if command_names == '' | return | endif execute 'syntax keyword vimCommand ' . command_names endfunction "}}} "--------------------------------------------------------------------------- " Plugin:"{{{ " " neocomplcache.vim"{{{ " Use neocomplcache. let g:neocomplcache_enable_at_startup = 1 let bundle = neobundle#get('neocomplcache') function! bundle.hooks.on_source(bundle) " Use smartcase. let g:neocomplcache_enable_smart_case = 0 " Use camel case completion. let g:neocomplcache_enable_camel_case_completion = 0 " Use underbar completion. let g:neocomplcache_enable_underbar_completion = 0 " Use fuzzy completion. let g:neocomplcache_enable_fuzzy_completion = 1 " Set minimum syntax keyword length. let g:neocomplcache_min_syntax_length = 3 " Set auto completion length. let g:neocomplcache_auto_completion_start_length = 2 " Set manual completion length. let g:neocomplcache_manual_completion_start_length = 0 " Set minimum keyword length. let g:neocomplcache_min_keyword_length = 3 " let g:neocomplcache_enable_cursor_hold_i = v:version > 703 || " \ v:version == 703 && has('patch289') let g:neocomplcache_enable_cursor_hold_i = 0 let g:neocomplcache_cursor_hold_i_time = 300 let g:neocomplcache_enable_insert_char_pre = 0 let g:neocomplcache_enable_prefetch = 0 let g:neocomplcache_skip_auto_completion_time = '0.6' if !exists('g:neocomplcache_wildcard_characters') let g:neocomplcache_wildcard_characters = {} endif let g:neocomplcache_wildcard_characters._ = '-' " For auto select. let g:neocomplcache_enable_auto_select = 1 let g:neocomplcache_enable_auto_delimiter = 1 "let g:neocomplcache_disable_caching_buffer_name_pattern = '[\[*]\%(unite\)[\]*]' let g:neocomplcache_disable_auto_select_buffer_name_pattern = '\[Command Line\]' " let g:neocomplcache_lock_buffer_name_pattern = '\.txt' "let g:neocomplcache_disable_auto_complete = 0 let g:neocomplcache_max_list = 100 let g:neocomplcache_force_overwrite_completefunc = 1 if $USER ==# 'root' let g:neocomplcache_temporary_dir = '/root/.neocon' endif if !exists('g:neocomplcache_omni_patterns') let g:neocomplcache_omni_patterns = {} endif if !exists('g:neocomplcache_force_omni_patterns') let g:neocomplcache_force_omni_patterns = {} endif " For clang_complete. let g:neocomplcache_force_overwrite_completefunc = 1 let g:neocomplcache_force_omni_patterns.c = \ '[^.[:digit:] *\t]\%(\.\|->\)' let g:neocomplcache_force_omni_patterns.cpp = \ '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' let g:clang_complete_auto = 0 let g:clang_auto_select = 0 let g:clang_use_library = 1 " For jedi-vim. let g:jedi#auto_initialization = 1 let g:jedi#popup_on_dot = 0 let g:jedi#rename_command = 'R' autocmd MyAutoCmd FileType python* \ NeoBundleSource jedi-vim | let b:did_ftplugin = 1 let g:neocomplcache_force_omni_patterns.python = '[^. \t]\.\w*' " Define dictionary. let g:neocomplcache_dictionary_filetype_lists = { \ 'default' : '', \ 'scheme' : expand('~/.gosh_completions'), \ 'scala' : expand('$DOTVIM/dict/scala.dict'), \ 'ruby' : expand('$DOTVIM/dict/ruby.dict'), \ 'int-termtter' : expand('~/.vimshell/int-history/int-termtter'), \ 'hoge' : expand('~/work/test.dic'), \ } let g:neocomplcache_omni_functions = { \ 'ruby' : 'rubycomplete#Complete', \ } " Define keyword pattern. 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['default'] = '[0-9a-zA-Z:#_]\+' let g:neocomplcache_keyword_patterns.perl = '\h\w*->\h\w*\|\h\w*::' if !exists('g:neocomplcache_omni_patterns') let g:neocomplcache_omni_patterns = {} endif " let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' " let g:neocomplcache_force_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' let g:neocomplcache_omni_patterns.php = '[^. *\t]\.\w*\|\h\w*::' let g:neocomplcache_omni_patterns.mail = '^\s*\w\+' let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' let g:neocomplcache_caching_limit_file_size = 500000 if !exists('g:neocomplcache_same_filetype_lists') let g:neocomplcache_same_filetype_lists = {} endif "let g:neocomplcache_same_filetype_lists.perl = 'ref' " let g:neocomplcache_source_look_dictionary_path = $HOME . '/words' let g:neocomplcache_source_look_dictionary_path = '' " Set $RSENSE_HOME path. let g:neocomplcache#sources#rsense#home_directory = '/opt/rsense' let g:neocomplcache_vim_completefuncs = { \ 'Ref' : 'ref#complete', \ 'Unite' : 'unite#complete_source', \ 'VimShellExecute' : \ 'vimshell#vimshell_execute_complete', \ 'VimShellInteractive' : \ 'vimshell#vimshell_execute_complete', \ 'VimShellTerminal' : \ 'vimshell#vimshell_execute_complete', \ 'VimShell' : 'vimshell#complete', \ 'VimFiler' : 'vimfiler#complete', \ 'Vinarise' : 'vinarise#complete', \} if !exists('g:neocomplcache_source_completion_length') let g:neocomplcache_source_completion_length = { \ 'look' : 4, \ } endif " Test."{{{ "let g:neocomplcache_auto_completion_start_length = 1 "let g:neocomplcache_plugin_completion_length = { "\ 'snippets_complete' : 1, "\ 'buffer_complete' : 2, "\ 'syntax_complete' : 2, "\ 'tags_complete' : 3, "\ 'vim_complete' : 4, "\ } let g:neocomplcache_source_disable = { \ 'tags_complete' : 1, \} "}}} " mappings."{{{ " , : page move. inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " : paste. inoremap pumvisible() ? neocomplcache#close_popup() : "\\"" " : close popup. inoremap pumvisible() ? neocomplcache#cancel_popup() : "\" " : unite completion. imap (neocomplcache_start_unite_complete) " - unite quick match. " imap - pumvisible() ? " \ "\(neocomplcache_start_unite_quick_match)" : '-' inoremap O &filetype == 'vim' ? "\\" : "\\" " , : close popup and delete backword char. inoremap neocomplcache#smart_close_popup()."\" inoremap neocomplcache#smart_close_popup()."\" " : neocomplcache. inoremap pumvisible() ? "\" : "\\\\" " : keyword completion. inoremap pumvisible() ? "\" : "\\" inoremap ' pumvisible() ? neocomplcache#close_popup() : "'" inoremap neocomplcache#manual_filename_complete() imap (neocomplcache_start_unite_snippet) " : close popup and save indent. inoremap =my_cr_function() function! s:my_cr_function() return neocomplcache#smart_close_popup() . "\" endfunction " : completion. inoremap pumvisible() ? "\" : \ check_back_space() ? "\" : \ neocomplcache#start_manual_complete() function! s:check_back_space() "{{{ let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction"}}} " : completion back. inoremap pumvisible() ? "\" : "\" " For cursor moving in insert mode(Not recommended) inoremap neocomplcache#close_popup() . "\" inoremap neocomplcache#close_popup() . "\" inoremap neocomplcache#close_popup() . "\" inoremap neocomplcache#close_popup() . "\" "}}} endfunction function! CompleteFiles(findstart, base) if a:findstart " Get cursor word. let cur_text = strpart(getline('.'), 0, col('.') - 1) return match(cur_text, '\f*$') endif let words = split(expand(a:base . '*'), '\n') let list = [] let cnt = 0 for word in words call add(list, { \ 'word' : word, \ 'abbr' : printf('%3d: %s', cnt, word), \ 'menu' : 'file_complete' \ }) let cnt += 1 endfor return { 'words' : list, 'refresh' : 'always' } endfunction "}}} " neosnippet.vim"{{{ let bundle = neobundle#get('neosnippet') function! bundle.hooks.on_source(bundle) imap L (neosnippet_jump_or_expand) smap L (neosnippet_jump_or_expand) xmap L (neosnippet_start_unite_snippet_target) imap K (neosnippet_expand_or_jump) smap K (neosnippet_expand_or_jump) imap G (neosnippet_expand) imap S (neosnippet_start_unite_snippet) xmap o (neosnippet_register_oneshot_snippet) xmap U (neosnippet_expand_target) let g:neosnippet#enable_snipmate_compatibility = 1 inoremap neocomplcache#undo_completion() inoremap neocomplcache#complete_common_string() " let g:snippets_dir = '~/.vim/snippets/,~/.vim/bundle/snipmate/snippets/' endfunction "}}} " echodoc.vim"{{{ let bundle = neobundle#get('echodoc') function! bundle.hooks.on_source(bundle) let g:echodoc_enable_at_startup = 1 endfunction "}}} " vimshell.vim"{{{ " Plugin key-mappings."{{{ " : switch to vimshell. nmap (vimshell_switch) nnoremap ! q:VimShellExecute nnoremap [Space]i q:VimShellInteractive nnoremap [Space]t q:VimShellTerminal nnoremap [Space]; :VimShellPop "}}} let bundle = neobundle#get('vimshell') function! bundle.hooks.on_source(bundle) " let g:vimshell_user_prompt = "3\ngetcwd()" let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")' " let g:vimshell_user_prompt = 'fnamemodify(getcwd(), ":~")' let g:vimshell_right_prompt = 'vcs#info("(%s)-[%b]%p", "(%s)-[%b|%a]%p")' let g:vimshell_prompt = '% ' "let g:vimshell_environment_term = 'xterm' let g:vimshell_split_command = '' let g:vimshell_enable_transient_user_prompt = 1 autocmd MyAutoCmd FileType vimshell call s:vimshell_settings() function! s:vimshell_settings() if s:is_windows " Display user name on Windows. "let g:vimshell_prompt = $USERNAME."% " " Use ckw. let g:vimshell_use_terminal_command = 'ckw -e' else " Display user name on Linux. "let g:vimshell_prompt = $USER."% " " Use zsh history. let g:vimshell_external_history_path = expand('~/.zsh-history') 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') " Use gnome-terminal. let g:vimshell_use_terminal_command = 'gnome-terminal -e' 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') inoremap ' pumvisible() ? "\" : "'" imap (vimshell_another_delete_backward_char) imap (vimshell_another_delete_backward_char) imap (vimshell_zsh_complete) nnoremap \ :Unite -buffer-name=files -default-action=lcd directory_mru call vimshell#altercmd#define('g', 'git') call vimshell#altercmd#define('i', 'iexe') call vimshell#altercmd#define('t', 'texe') call vimshell#set_alias('l.', 'ls -d .*') call vimshell#set_alias('gvim', 'gexe gvim') call vimshell#set_galias('L', 'ls -l') call vimshell#set_galias('time', 'exe time -p') " Auto jump. call vimshell#set_alias('j', ':Unite -buffer-name=files \ -default-action=lcd -input=$$args directory_mru') call vimshell#hook#add('chpwd', 'my_chpwd', s:vimshell_hooks.chpwd) call vimshell#hook#add('emptycmd', 'my_emptycmd', s:vimshell_hooks.emptycmd) call vimshell#hook#add('preprompt', 'my_preprompt', s:vimshell_hooks.preprompt) call vimshell#hook#add('preexec', 'my_preexec', s:vimshell_hooks.preexec) " call vimshell#hook#set('preexec', [s:SID_PREFIX() . 'vimshell_hooks_preexec']) endfunction autocmd MyAutoCmd FileType int-* call s:interactive_settings() function! s:interactive_settings() call vimshell#hook#set('input', [s:vimshell_hooks.input]) endfunction autocmd MyAutoCmd FileType term-* call s:terminal_settings() function! s:terminal_settings() inoremap (vimshell_term_send_semicolon) \ vimshell#term_mappings#send_key(';') inoremap j \ vimshell#term_mappings#send_key('j') "inoremap " \ vimshell#term_mappings#send_keys("\[A") " Sticky key. imap ; texe_sticky_func() " Escape key. iunmap imap (vimshell_term_send_escape) endfunction function! s:texe_sticky_func() let sticky_table = { \',' : '<', '.' : '>', '/' : '?', \'1' : '!', '2' : '@', '3' : '#', '4' : '$', '5' : '%', \'6' : '^', '7' : '&', '8' : '*', '9' : '(', '0' : ')', '-' : '_', '=' : '+', \';' : ':', '[' : '{', ']' : '}', '`' : '~', "'" : "\"", '\' : '|', \} let special_table = { \ "\" : "\", "\" : ";\" \ "\" : "\(vimshell_term_send_semicolon)", \} if mode() !~# '^c' echo 'Input sticky key: ' endif let char = '' while char == '' let char = nr2char(getchar()) endwhile if char =~ '\l' return toupper(char) elseif has_key(sticky_table, char) return sticky_table[char] elseif has_key(special_table, char) return special_table[char] else return '' endif endfunction let s:vimshell_hooks = {} function! s:vimshell_hooks.chpwd(args, context) if len(split(glob('*'), '\n')) < 100 call vimshell#execute('ls') else call vimshell#execute('echo "Many files."') endif endfunction function! s:vimshell_hooks.emptycmd(cmdline, context) call vimshell#set_prompt_command('ls') return 'ls' endfunction function! s:vimshell_hooks.preprompt(args, context) " call vimshell#execute('echo "preprompt"') endfunction function! s:vimshell_hooks.preexec(cmdline, context) " call vimshell#execute('echo "preexec"') let args = vimproc#parser#split_args(a:cmdline) if len(args) > 0 && args[0] ==# 'diff' call vimshell#set_syntax('diff') endif return a:cmdline endfunction function! s:vimshell_hooks.input(input, context) " echomsg 'input' return a:input endfunction endfunction "}}} " netrw.vim"{{{ let g:netrw_list_hide= '*.swp' nnoremap :Explore " Change default directory. set browsedir=current "}}} " vinarise.vim"{{{ let g:vinarise_enable_auto_detect = 1 "}}} " vim-versions{{{ nnoremap [Space]gs :UniteVersions status:! "}}} " unite.vim"{{{ " The prefix key. nnoremap [unite] xnoremap [unite] nmap ;u [unite] xmap ;u [unite] nnoremap [unite]u q:Unite " nnoremap : :Unite history/command command nnoremap ;b unite_build() function! s:unite_build() return ":\Unite -buffer-name=build". tabpagenr() ." -no-quit build\" endfunction nnoremap ;o \ :Unite outline -start-insert -resume nnoremap [unite]f :Unite source nnoremap ;t \ :UniteWithCursorWord -buffer-name=tag tag tag/include xnoremap ;r \ d:Unite -buffer-name=register register history/yank nnoremap ;w \ :UniteWithCursorWord -buffer-name=register \ buffer file_mru bookmark file nnoremap \ :Unite change jump nnoremap ;g \ :Unite grep -buffer-name=search -no-quit -resume nnoremap ;r \ :Unite -buffer-name=register register history/yank inoremap \ unite#start_complete('register', { 'input': unite#get_cur_text() }) " : Tab pages nnoremap :Unite tab " : Windows operation nnoremap :Unite window "}}} if s:is_windows nnoremap [Window]s \ :Unite -buffer-name=files -no-split -multi-line \ jump_point file_point buffer_tab \ file_rec:! file file/new file_mru else nnoremap [Window]s \ :Unite -buffer-name=files -no-split -multi-line \ jump_point file_point buffer_tab \ file_rec/async:! file file/new file_mru endif nnoremap [Window]w \ :Unite window nnoremap [Space]b \ :UniteBookmarkAdd " t: tags-and-searches "{{{ " The prefix key. nnoremap [Tag] nmap t [Tag] " Jump. " nnoremap [Tag]t nnoremap [Tag]t &filetype == 'help' ? "\" : \ ":\UniteWithCursorWord -buffer-name=tag tag tag/include\" " Jump next. nnoremap [Tag]n :tag " Jump previous. " nnoremap [Tag]p :pop nnoremap [Tag]p &filetype == 'help' ? \ ":\pop\" : ":\Unite jump\" "}}} " Execute help. nnoremap :Unite -buffer-name=help help " Execute help by cursor keyword. nnoremap g :UniteWithInput help " Search. nnoremap / smart_search_expr( \ ":\Unite -buffer-name=search -no-split -start-insert line/fast\", \ ":\Unite -buffer-name=search -start-insert line\") nnoremap g/ smart_search_expr('g/', \ ":\Unite -buffer-name=search -start-insert line_migemo\") nnoremap [Alt]/ g/ nnoremap ? smart_search_expr('?', \ ":\Unite mapping\") nnoremap * smart_search_expr( \ ":\UniteWithCursorWord -buffer-name=search line/fast\", \ ":\UniteWithCursorWord -buffer-name=search line\") function! s:smart_search_expr(expr1, expr2) return line('$') > 5000 ? a:expr1 : a:expr2 endfunction nnoremap n \ :UniteResume search -no-start-insert let g:unite_source_history_yank_enable = 1 let bundle = neobundle#get('unite.vim') function! bundle.hooks.on_source(bundle) autocmd MyAutoCmd FileType unite call s:unite_my_settings() call unite#set_profile('action', 'context', {'start_insert' : 1}) " Set "-no-quit" automatically in grep unite source. call unite#set_profile('source/grep', 'context', {'no_quit' : 1}) " migemo. call unite#custom_source('line_migemo', 'matchers', 'matcher_migemo') " Custom filters."{{{ " call unite#custom_source('file,buffer,file_rec', 'matchers', 'matcher_fuzzy') call unite#filters#sorter_default#use(['sorter_rank']) "}}} function! s:unite_my_settings() "{{{ " Directory partial match. " call unite#set_substitute_pattern('files', " \'\%([~.*]\+\)\@ (unite_delete_backward_path) imap jj (unite_insert_leave) imap j unite#smart_map('j', '') imap (unite_select_next_line) imap (unite_delete_backward_path) imap ' (unite_quick_match_default_action) nmap ' (unite_quick_match_default_action) imap x \ unite#smart_map('x', "\(unite_quick_match_choose_action)") nmap x (unite_quick_match_choose_action) nmap cd (unite_quick_match_default_action) nmap (unite_toggle_transpose_window) imap (unite_toggle_transpose_window) imap (unite_narrowing_path) nmap (unite_narrowing_path) nmap (unite_toggle_auto_preview) " nmap (unite_narrowing_input_history) " imap (unite_narrowing_input_history) nmap :call NextWindow() nnoremap l \ unite#smart_map('l', unite#do_action('default')) nmap (unite_narrowing_input_history) let unite = unite#get_current_unite() if unite.buffer_name =~# '^search' nnoremap r unite#do_action('replace') else nnoremap r unite#do_action('rename') endif nnoremap cd unite#do_action('lcd') nnoremap S unite#mappings#set_current_filters( \ empty(unite#mappings#get_current_filters()) ? ['sorter_reverse'] : []) endfunction"}}} " Original source."{{{ let source = { \ 'name' : 'buffer_lines', \ 'description' : 'candidates from current buffer lines', \ 'action_table' : {}, \ 'max_candidates' : 30, \ 'hooks' : {}, \ } call unite#define_source(source) function! source.hooks.on_init(args, context) "{{{ let a:context.source__lines = getbufline(bufnr('%'), 1, '$') let a:context.source__bufname = bufname('%') endfunction"}}} function! source.gather_candidates(args, context) "{{{ let candidates = [] let linenr = 1 for line in a:context.source__lines call add(candidates, { \ 'word' : line, \ 'kind' : 'jump_list', \ 'action__line' : linenr, \ 'action__path' : a:context.source__bufname, \ }) let linenr += 1 endfor return candidates endfunction"}}} unlet source "}}} " Variables. let g:unite_enable_split_vertically = 0 let g:unite_winheight = 20 let g:unite_enable_start_insert = 0 let g:unite_enable_short_source_names = 1 let g:unite_cursor_line_highlight = 'TabLineSel' " let g:unite_abbr_highlight = 'TabLine' " let g:unite_source_file_mru_time_format = '' let g:unite_source_file_mru_filename_format = ':~:.' let g:unite_source_file_mru_limit = 300 " let g:unite_source_directory_mru_time_format = '' let g:unite_source_directory_mru_limit = 300 if s:is_windows else " Like Textmate icons. let g:unite_marked_icon = '✗' endif if executable('jvgrep') " For jvgrep. let g:unite_source_grep_command = 'jvgrep' let g:unite_source_grep_default_opts = '--exclude ''\.(git|svn|hg|bzr)''' let g:unite_source_grep_recursive_opt = '-R' elseif executable('ack-grep') " For ack. " let g:unite_source_grep_command = 'ack-grep' " let g:unite_source_grep_default_opts = '--no-heading --no-color -a' " let g:unite_source_grep_recursive_opt = '' endif " For unite-alias. let g:unite_source_alias_aliases = {} let g:unite_source_alias_aliases.test = { \ 'source' : 'file_rec', \ 'args' : '~/', \ } let g:unite_source_alias_aliases.line_migemo = { \ 'source' : 'line', \ } " For unite-menu. let g:unite_source_menu_menus = {} let g:unite_source_menu_menus.enc = { \ 'description' : 'Open with a specific character code again.', \ } let g:unite_source_menu_menus.enc.command_candidates = [ \ ['utf8', 'Utf8'], \ ['iso2022jp', 'Iso2022jp'], \ ['cp932', 'Cp932'], \ ['euc', 'Euc'], \ ['utf16', 'Utf16'], \ ['utf16-be', 'Utf16be'], \ ['jis', 'Jis'], \ ['sjis', 'Sjis'], \ ['unicode', 'Unicode'], \ ] nnoremap ;e :Unite menu:enc let g:unite_source_menu_menus.fenc = { \ 'description' : 'Change file fenc option.', \ } let g:unite_source_menu_menus.fenc.command_candidates = [ \ ['utf8', 'WUtf8'], \ ['iso2022jp', 'WIso2022jp'], \ ['cp932', 'WCp932'], \ ['euc', 'WEuc'], \ ['utf16', 'WUtf16'], \ ['utf16-be', 'WUtf16be'], \ ['jis', 'WJis'], \ ['sjis', 'WSjis'], \ ['unicode', 'WUnicode'], \ ] nnoremap ;f :Unite menu:fenc let g:unite_source_menu_menus.ff = { \ 'description' : 'Change file format option.', \ } let g:unite_source_menu_menus.ff.command_candidates = { \ 'unix' : 'WUnix', \ 'dos' : 'WDos', \ 'mac' : 'WMac', \ } nnoremap ;w :Unite menu:ff let g:unite_source_menu_menus.unite = { \ 'description' : 'Start unite sources', \ } let g:unite_source_menu_menus.unite.command_candidates = { \ 'history' : 'Unite history/command', \ 'quickfix' : 'Unite qflist -no-quit', \ 'resume' : 'Unite -buffer-name=resume resume', \ 'directory' : 'Unite -buffer-name=files '. \ '-default-action=lcd directory_mru', \ 'mapping' : 'Unite mapping', \ 'message' : 'Unite output:message', \ } nnoremap ;u :Unite menu:unite -resume let g:unite_build_error_icon = $DOTVIM . '/signs/err.' \ . (s:is_windows ? 'bmp' : 'png') let g:unite_build_warning_icon = $DOTVIM . '/signs/warn.' \ . (s:is_windows ? 'bmp' : 'png') endfunction "}}} " smartword.vim"{{{ " Replace w and others with smartword-mappings nmap w (smartword-w) nmap b (smartword-b) nmap ge (smartword-ge) xmap w (smartword-w) xmap b (smartword-b) " Operator pending mode. omap w (smartword-w) omap b (smartword-b) omap ge (smartword-ge) "}}} " camlcasemotion.vim"{{{ nmap W CamelCaseMotion_w xmap W CamelCaseMotion_w nmap B CamelCaseMotion_b xmap B CamelCaseMotion_b ""}}} " smartchr.vim"{{{ let bundle = neobundle#get('vim-smartchr') function! bundle.hooks.on_source(bundle) inoremap , smartchr#one_of(', ', ',') inoremap ? smartchr#one_of('?', '? ') " Smart =. inoremap = \ search('\(&\\+\-\/\>\<\) \%#', 'bcn')? '= ' \ : search('\(*\!\)\%#', 'bcn') ? '= ' \ : smartchr#one_of(' = ', '=', ' == ') augroup MyAutoCmd " Substitute .. into -> . autocmd FileType c,cpp inoremap . smartchr#loop('.', '->', '...') autocmd FileType perl,php inoremap . smartchr#loop(' . ', '->', '.') autocmd FileType perl,php inoremap - smartchr#loop('-', '->') autocmd FileType vim inoremap . smartchr#loop('.', ' . ', '..', '...') autocmd FileType haskell,int-ghci \ inoremap + smartchr#loop('+', ' ++ ') \| inoremap - smartchr#loop('-', ' -> ', ' <- ') \| inoremap $ smartchr#loop(' $ ', '$') \| inoremap \ smartchr#loop('\ ', '\') \| inoremap : smartchr#loop(':', ' :: ', ' : ') \| inoremap . smartchr#loop('.', ' . ', '..') autocmd FileType scala \ inoremap - smartchr#loop('-', ' -> ', ' <- ') \| inoremap = smartchr#loop(' = ', '=', ' => ') \| inoremap : smartchr#loop(': ', ':', ' :: ') \| inoremap . smartchr#loop('.', ' => ') autocmd FileType eruby \ inoremap > smartchr#loop('>', '%>') \| inoremap < smartchr#loop('<', '<%', '<%=') augroup END endfunction "}}} " smarttill.vim"{{{ xmap q (smarttill-t) xmap Q (smarttill-T) " Operator pending mode. omap q (smarttill-t) omap Q (smarttill-T) "}}} " changelog.vim"{{{ autocmd MyAutoCmd BufNewFile,BufRead *.changelog setf changelog let g:changelog_timeformat = "%Y-%m-%d" let g:changelog_username = "Shougo " "}}} " quickrun.vim"{{{ function! s:init_quickrun() for [key, com] in items({ \ 'x' : '<=@i >:', \ 'p' : '<=@i >!', \ '"' : '<=@i >=@"', \ 'w' : '<=@i >', \ 'q' : '<=@i >>', \ 'vx' : '-eval 1 <=@i >:', \ 'vp' : '-eval 1 <=@i >!', \ 'v"' : '-eval 1 <=@i >=@"', \ 'vw' : '-eval 1 <=@i >', \ 'vq' : '-eval 1 <=@i >>', \ }) execute 'nnoremap ' key ':QuickRun' com '-mode n' execute 'vnoremap ' key ':QuickRun' com '-mode v' endfor call s:set_default('g:QuickRunConfig', {'mkd': {'command': 'mdv2html'}}) call s:set_default('g:QuickRunConfig', {'xmodmap': {}}) endfunction call s:init_quickrun() nmap [Space]r (quickrun-op) if !exists('g:quickrun_config') " Enable async. let g:quickrun_config = { \ '*': {'runmode': 'async:vimproc'}, \ } if s:is_windows function! TexEncoding() if &fileencoding ==# 'utf-8' let arg = 'utf8 ' elseif &fileencoding =~# '^euc-\%(jp\|jisx0213\)$' let arg = 'euc ' elseif &fileencoding =~# '^iso-2022-jp' let arg = 'jis ' else " cp932 let arg = 'sjis ' endif return arg endfunction let tex = 'platex -kanji={TexEncoding()}' let g:quickrun_config.tex = { 'command' : tex, 'exec': ['%c %s', 'dvipdfmx %s:r.dvi'] } else let tex = 'platex' let g:quickrun_config.tex = { 'command' : tex, 'exec': ['%c %s', 'dvipdfmx %s:r.dvi', 'open %s:r.pdf'] } endif unlet tex let g:quickrun_config.vim = {} endif "}}} " python.vim let python_highlight_all = 1 " fakeclip.vim"{{{ let g:fakeclip_no_default_key_mappings = 1 for _ in ['+', '*'] execute 'silent! nmap "'._.'y (fakeclip-y)' execute 'silent! nmap "'._.'Y (fakeclip-Y)' execute 'silent! nmap "'._.'yy (fakeclip-Y)' execute 'silent! vmap "'._.'y (fakeclip-y)' execute 'silent! vmap "'._.'Y (fakeclip-Y)' execute 'silent! nmap "'._.'p (fakeclip-p)' execute 'silent! nmap "'._.'P (fakeclip-P)' execute 'silent! nmap "'._.'gp (fakeclip-gp)' execute 'silent! nmap "'._.'gP (fakeclip-gP)' execute 'silent! vmap "'._.'p (fakeclip-p)' execute 'silent! vmap "'._.'P (fakeclip-P)' execute 'silent! vmap "'._.'gp (fakeclip-gp)' execute 'silent! vmap "'._.'gP (fakeclip-gP)' "execute 'silent! map! '._.' (fakeclip-insert)' "execute 'silent! map! '._.' (fakeclip-insert-r)' "execute 'silent! map! '._.' (fakeclip-insert-o)' "execute 'silent! imap '._.' (fakeclip-insert-p)' endfor "}}} " ref.vim"{{{ let bundle = neobundle#get('vim-ref') function! bundle.hooks.on_source(bundle) let g:ref_use_vimproc = 1 if s:is_windows let g:ref_refe_encoding = 'cp932' else let g:ref_refe_encoding = 'euc-jp' endif " ref-lynx. if s:is_windows let s:lynx = 'C:/lynx/lynx.exe' let s:cfg = 'C:/lynx/lynx.cfg' let g:ref_lynx_cmd = s:lynx.' -cfg='.s:cfg.' -dump -nonumbers %s' let g:ref_alc_cmd = s:lynx.' -cfg='.s:cfg.' -dump %s' unlet s:lynx unlet s:cfg endif let g:ref_lynx_use_cache = 1 let g:ref_lynx_start_linenumber = 0 " Skip. let g:ref_lynx_hide_url_number = 0 autocmd MyAutoCmd FileType ref call s:ref_my_settings() function! s:ref_my_settings() "{{{ " Overwrite settings. nmap [Tag]t (ref-keyword) nmap [Tag]p (ref-back) endfunction"}}} endfunction "}}} " vimfiler.vim"{{{ "nmap [Space]v (vimfiler_switch) nnoremap [Space]v :VimFiler nnoremap [Space]ff :VimFilerExplorer let bundle = neobundle#get('vimfiler') function! bundle.hooks.on_source(bundle) let g:vimfiler_enable_clipboard = 0 let g:vimfiler_safe_mode_by_default = 0 let g:vimfiler_as_default_explorer = 1 let g:vimfiler_detect_drives = s:is_windows ? [ \ 'C:/', 'D:/', 'E:/', 'F:/', 'G:/', 'H:/', 'I:/', \ 'J:/', 'K:/', 'L:/', 'M:/', 'N:/'] : \ split(glob('/mnt/*'), '\n') + split(glob('/media/*'), '\n') + \ split(glob('/Users/*'), '\n') " %p : full path " %d : current directory " %f : filename " %F : filename removed extensions " %* : filenames " %# : filenames fullpath let g:vimfiler_sendto = { \ 'unzip' : 'unzip %f', \ 'zip' : 'zip -r %F.zip %*', \ 'Inkscape' : 'inkspace', \ 'GIMP' : 'gimp %*', \ 'gedit' : 'gedit', \ } if s:is_windows " Use trashbox. let g:unite_kind_file_use_trashbox = 1 else " Like Textmate icons. let g:vimfiler_tree_leaf_icon = ' ' let g:vimfiler_tree_opened_icon = '▾' let g:vimfiler_tree_closed_icon = '▸' let g:vimfiler_file_icon = '-' let g:vimfiler_readonly_file_icon = '✗' let g:vimfiler_marked_file_icon = '✓' endif " let g:vimfiler_readonly_file_icon = '[O]' let g:vimfiler_quick_look_command = \ s:is_windows ? 'maComfort.exe -ql' : \ s:is_mac ? 'qlmanage -p' : 'gloobus-preview' autocmd MyAutoCmd FileType vimfiler call s:vimfiler_my_settings() function! s:vimfiler_my_settings() "{{{ call vimfiler#set_execute_file('vim', ['vim', 'notepad']) call vimfiler#set_execute_file('txt', 'vim') " Overwrite settings. nnoremap J \ :Unite -buffer-name=files -default-action=lcd directory_mru " Call sendto. " nnoremap - :Unite sendto " setlocal cursorline nmap O (vimfiler_sync_with_another_vimfiler) nnoremap gy vimfiler#do_action('tabopen') nmap p (vimfiler_quick_look) " Migemo search. if !empty(unite#get_filters('matcher_migemo')) nnoremap / line('$') > 10000 ? 'g/' : \ ":\Unite -buffer-name=search -start-insert line_migemo\" endif endfunction"}}} endfunction "}}} " eskk.vim"{{{ imap (eskk:toggle) let bundle = neobundle#get('eskk.vim') function! bundle.hooks.on_source(bundle) let g:eskk#large_dictionary = { \ 'path': expand('~/SKK-JISYO.L'), \ 'sorted': 1, \ 'encoding': 'euc-jp', \} " Disable skk.vim let g:plugin_skk_disable = 1 let g:eskk#disable = 0 let g:eskk#debug = 0 " Don't keep state. let g:eskk#keep_state = 0 let g:eskk#show_annotation = 1 let g:eskk#rom_input_style = 'msime' let g:eskk#egg_like_newline = 1 let g:eskk#egg_like_newline_completion = 1 " Disable mapping. "let g:eskk#map_normal_keys = 0 " Toggle debug. nnoremap [Space]ed :call ToggleVariable('g:eskk#debug') autocmd MyAutoCmd User eskk-initialize-post \ EskkMap -remap jj (eskk:disable) "let g:eskk#dictionary = { "\ 'path': expand('~/.skk-eskk-jisyo'), "\ 'sorted': 0, "\ 'encoding': 'utf-8', "\} " Use /bin/sh -c "VTE_CJK_WIDTH=1 gnome-terminal --disable-factory" " instead of this settings. "if &encoding == 'utf-8' && !has('gui_running') " GNOME Terminal only. " Use <> instead of ▽. "let g:eskk#marker_henkan = '<>' " Use >> instead of ▼. "let g:eskk#marker_henkan_select = '>>' "endif " Define table. autocmd MyAutoCmd User eskk-initialize-pre call s:eskk_initial_pre() function! s:eskk_initial_pre() "{{{ let t = eskk#table#new('rom_to_hira*', 'rom_to_hira') call t.add_map('z ', ' ') call t.add_map('~', '〜') call t.add_map('zc', '©') call t.add_map('zr', '®') call t.add_map('z9', '(') call t.add_map('z0', ')') call eskk#register_mode_table('hira', t) unlet t endfunction "}}} endfunction "}}} " lingr-vim"{{{ let g:lingr_vim_sidebar_width = 30 " Keymappings. autocmd MyAutoCmd FileType lingr-messages call s:lingr_messages_my_settings() autocmd MyAutoCmd FileType lingr-say call s:lingr_say_my_settings() autocmd MyAutoCmd FileType lingr-rooms call s:lingr_looms_my_settings() function! s:lingr_messages_my_settings() "{{{ nmap o (lingr-messages-show-say-buffer) nunmap s if s:is_windows " Dirty shellslash hack. set noshellslash augroup MyAutoCmd autocmd WinEnter,BufWinEnter set noshellslash autocmd WinLeave,BufWinLeave set shellslash augroup END endif endfunction"}}} function! s:lingr_say_my_settings() "{{{ imap (lingr-say-insert-mode-say) nmap q (lingr-say-close) endfunction"}}} function! s:lingr_looms_my_settings() "{{{ nmap l (lingr-rooms-select-room) endfunction"}}} if !s:is_windows command! Suicide call system('kill -KILL ' . getpid()) endif "}}} " surround.vim"{{{ let g:surround_no_mappings = 1 autocmd MyAutoCmd FileType * call s:define_surround_keymappings() function! s:define_surround_keymappings() if !&modifiable silent! nunmap ds silent! nunmap cs silent! nunmap ys silent! nunmap yS else nmap ds Dsurround nmap cs Csurround nmap ys Ysurround nmap yS YSurround endif endfunction "}}} " qfreplace.vim autocmd MyAutoCmd FileType qf nnoremap r :Qfreplace " open-browser.vim"{{{ nmap gs (open-browser-wwwsearch) let bundle = neobundle#get('open-browser.vim') function! bundle.hooks.on_source(bundle) nnoremap (open-browser-wwwsearch) \ :call www_search() function! s:www_search() let search_word = input('Please input search word: ', '', \ 'customlist,wwwsearch#cmd_Wwwsearch_complete') if search_word != '' execute 'OpenBrowserSearch' escape(search_word, '"') endif endfunction endfunction "}}} " caw.vim"{{{ nmap gc (caw:prefix) xmap gc (caw:prefix) nmap gcc (caw:i:toggle) xmap gcc (caw:i:toggle) "}}} " autodate.vim"{{{ let autodate_format = '%d %3m %Y' let autodate_keyword_pre = 'Last \%(Change\|Modified\):' "}}} " Conque.vim"{{{ let g:ConqueTerm_EscKey = '' let g:ConqueTerm_PyVersion = 3 "}}} " fontzoom.vim"{{{ nmap + (fontzoom-larger) nmap _ (fontzoom-smaller) "}}} " surround_custom_mappings.vim"{{{ let bundle = neobundle#get('vim-surround_custom_mapping') function! bundle.hooks.on_source(bundle) let g:surround_custom_mapping = {} let g:surround_custom_mapping._ = { \ 'p': "
 \r 
", \ 'w': "%w(\r)", \ } let g:surround_custom_mapping.help = { \ 'p': "> \r <", \ } let g:surround_custom_mapping.ruby = { \ '-': "<% \r %>", \ '=': "<%= \r %>", \ '9': "(\r)", \ '5': "%(\r)", \ '%': "%(\r)", \ 'w': "%w(\r)", \ '#': "#{\r}", \ '3': "#{\r}", \ 'e': "begin \r end", \ 'E': "<GundoToggle " TweetVim " Start TweetVim. nnoremap [unite]w :Unite tweetvim autocmd MyAutoCmd FileType tweetvim call s:tweetvim_my_settings() function! s:tweetvim_my_settings() "{{{ " Open say buffer. nnoremap o :TweetVimSay nnoremap q :close nmap j (accelerated_jk_gj) endfunction"}}} let g:tweetvim_display_separator = 0 " Operator-replace. nmap R (operator-replace) xmap R (operator-replace) xmap p (operator-replace) " Taglist. let Tlist_Show_One_File = 1 let Tlist_Use_Right_Window = 1 let Tlist_Exit_OnlyWindow = 1 " restart.vim {{{ let g:restart_save_window_values = 0 nnoremap [Space]re :Restart "}}} " accelerated-jk nmap j (accelerated_jk_gj) nmap gj j nmap k (accelerated_jk_gk) nmap gk k " tabpagecd autocmd MyAutoCmd TabEnter * NeoBundleSource vim-tabpagecd " altercmd.vim{{{ nnoremap : :NeoBundleSource vim-altercmd: let bundle = neobundle#get('vim-altercmd') function! bundle.hooks.on_source(bundle) silent! nunmap : silent! xunmap : call altercmd#load() AlterCommand u[nite] Unite AlterCommand u[nite] Unite AlterCommand u[nite] Unite AlterCommand u[nite] Unite AlterCommand e[dit] Edit AlterCommand e[dit] Edit AlterCommand r[ead] Read AlterCommand r[ead] Read AlterCommand s[ource] Source AlterCommand s[ource] Source AlterCommand w[rite] Write AlterCommand w[rite] Write endfunction "}}} "}}} "--------------------------------------------------------------------------- " Key-mappings: "{{{ " " Use . map cmap " Visual mode keymappings: "{{{ " : indent. xnoremap > " : unindent. xnoremap < " Indent nnoremap > >> nnoremap < << xnoremap > >gv xnoremap < y "*y:let [@+,@"]=[@*,@*] "}}} " Insert mode keymappings: "{{{ " : insert tab. inoremap " : delete char. inoremap " : move to head. inoremap ^ " Enable undo and . inoremap u inoremap u if has('gui_running') inoremap endif " H, D: delete camlcasemotion. inoremap H camelcase_delete(0) inoremap D camelcase_delete(1) function! s:camelcase_delete(is_reverse) let save_ve = &l:virtualedit setlocal virtualedit=all if a:is_reverse let cur_text = getline('.')[virtcol('.')-1 : ] else let cur_text = getline('.')[: virtcol('.')-2] endif let &l:virtualedit = save_ve let pattern = '\d\+\|\u\+\ze\%(\u\l\|\d\)\|' . \'\u\l\+\|\%(\a\|\d\)\+\ze_\|\%(\k\@!\S\)\+' . \'\|\%(_\@!\k\)\+\>\|[_]\|\s\+' if a:is_reverse let cur_cnt = len(matchstr(cur_text, '^\%('.pattern.'\)')) else let cur_cnt = len(matchstr(cur_text, '\%('.pattern.'\)$')) endif let del = a:is_reverse ? "\" : "\" return (pumvisible() ? neocomplcache#smart_close_popup() : '') . repeat(del, cur_cnt) endfunction "}}} " Command-line mode keymappings:"{{{ " , A: move to head. cnoremap " : previous char. cnoremap " : delete char. cnoremap " , E: move to end. cnoremap " : next char. cnoremap " : next history. cnoremap " : previous history. cnoremap " , K: delete to end. cnoremap e getcmdpos() == 1 ? \ '' : getcmdline()[:getcmdpos()-2] " : paste. cnoremap * "}}} " Command line buffer."{{{ nnoremap (command-line-enter) q: xnoremap (command-line-enter) q: nnoremap (command-line-norange) q: nmap ;; (command-line-enter) xmap ;; (command-line-enter) autocmd MyAutoCmd CmdwinEnter * call s:init_cmdwin() autocmd MyAutoCmd CmdwinLeave * let g:neocomplcache_enable_auto_select = 1 function! s:init_cmdwin() NeoBundleSource vim-altercmd let g:neocomplcache_enable_auto_select = 0 let b:neocomplcache_sources_list = ['vim_complete'] nnoremap q :quit nnoremap :quit inoremap neocomplcache#close_popup()."\" inoremap col('.') == 1 ? \ "\:quit\" : neocomplcache#cancel_popup()."\" inoremap col('.') == 1 ? \ "\:quit\" : neocomplcache#cancel_popup()."\" " Completion. inoremap pumvisible() ? \ "\" : check_back_space() ? "\" : "\\\" startinsert! endfunction"}}} " [Space]: Other useful commands "{{{ " Smart space mapping. " Notice: when starting other mappings in noremap, disappeared [Space]. nmap [Space] xmap [Space] nnoremap [Space] xnoremap [Space] " Toggle relativenumber. nnoremap [Space]. \ :call ToggleOption('relativenumber') nnoremap [Space]p \ :call ToggleOption('paste') " Toggle highlight. nnoremap [Space]/ \ :call ToggleOption('hlsearch') " Toggle cursorline. nnoremap [Space]cl \ :call ToggleOption('cursorline') " Set autoread. nnoremap [Space]ar \ :setlocal autoread " Output encoding information. nnoremap [Space]en \ :setlocal encoding? termencoding? fenc? fencs? " Set spell check. nnoremap [Space]sp \ :call ToggleOption('spell') nnoremap [Space]w \ :call ToggleOption('wrap') " Echo syntax name. nnoremap [Space]sy \ :echo synIDattr(synID(line('.'), col('.'), 1), "name") " Easily edit .vimrc and .gvimrc "{{{ nnoremap [Space]ev :edit $MYVIMRC nnoremap [Space]eg :edit $MYGVIMRC " Load .gvimrc after .vimrc edited at GVim. nnoremap [Space]rv :source $MYVIMRC \| \ if has('gui_running') \| \ source $MYGVIMRC \| \ endif \| echo "source $MYVIMRC" nnoremap [Space]rg \ :source $MYGVIMRC \| \ echo "source $MYGVIMRC" "}}} " Useful save mappings. nnoremap :update " Change current directory. nnoremap [Space]cd :call cd_buffer_dir() function! s:cd_buffer_dir() "{{{ let filetype = getbufvar(bufnr('%'), '&filetype') if filetype ==# 'vimfiler' let dir = getbufvar(bufnr('%'), 'vimfiler').current_dir elseif filetype ==# 'vimshell' let dir = getbufvar(bufnr('%'), 'vimshell').save_dir else let dir = isdirectory(bufname('%')) ? bufname('%') : fnamemodify(bufname('%'), ':p:h') endif cd `=dir` endfunction"}}} " Delete windows ^M codes. nnoremap [Space] mmHmt:%s/$//ge'tzt'm " Delete spaces before newline. nnoremap [Space]ss mmHmt:%s/$//ge`tzt`m " Easily syntax change. nnoremap [Space]ft :Unite -start-insert filetype " Exchange gj and gk to j and k. "{{{ command! -nargs=? -bar -bang ToggleGJK call s:ToggleGJK() nnoremap [Space]gj :ToggleGJK xnoremap [Space]gj :ToggleGJK function! s:ToggleGJK() if exists('b:enable_mapping_gjk') && b:enable_mapping_gjk let b:enable_mapping_gjk = 0 noremap j j noremap k k noremap gj gj noremap gk gk xnoremap j j xnoremap k k xnoremap gj gj xnoremap gk gk else let b:enable_mapping_gjk = 1 noremap j gj noremap k gk noremap gj j noremap gk k xnoremap j gj xnoremap k gk xnoremap gj j xnoremap gk k endif endfunction"}}} " Change tab width. "{{{ nnoremap [Space]t2 :setl shiftwidth=2 softtabstop=2 nnoremap [Space]t4 :setl shiftwidth=4 softtabstop=4 nnoremap [Space]t8 :setl shiftwidth=8 softtabstop=8 "}}} "}}} " s: Windows and buffers(High priority) "{{{ " The prefix key. nnoremap [Window] nmap s [Window] nnoremap [Window]p :call split_nicely() nnoremap [Window]v :vsplit nnoremap [Window]c :call smart_close() nnoremap - :call smart_close() nnoremap [Window]o :only " A .vimrc snippet that allows you to move around windows beyond tabs nnoremap :call NextWindow() nnoremap :call PreviousWindowOrTab() function! s:smart_close() if winnr('$') != 1 close endif endfunction function! s:NextWindow() if winnr('$') == 1 silent! normal! ``z. else wincmd w endif endfunction function! s:NextWindowOrTab() if tabpagenr('$') == 1 && winnr('$') == 1 call s:split_nicely() elseif winnr() < winnr("$") wincmd w else tabnext 1wincmd w endif endfunction function! s:PreviousWindowOrTab() if winnr() > 1 wincmd W else tabprevious execute winnr("$") . "wincmd w" endif endfunction nnoremap [Window] :call ToggleSplit() " If window isn't splited, split buffer. function! s:ToggleSplit() let prev_name = winnr() silent! wincmd w if prev_name == winnr() SplitNicely else call s:smart_close() endif endfunction " Split nicely."{{{ command! SplitNicely call s:split_nicely() function! s:split_nicely() " Split nicely. if winwidth(0) > 2 * &winwidth vsplit else split endif wincmd p endfunction "}}} " Delete current buffer."{{{ nnoremap [Window]d :call CustomBufferDelete(0) " Force delete current buffer. nnoremap [Window]D :call CustomBufferDelete(1) function! s:CustomBufferDelete(is_force) let current = bufnr('%') call unite#util#alternate_buffer() if a:is_force silent! execute 'bdelete! ' . current else silent! execute 'bdelete ' . current endif endfunction "}}} " JunkFile nnoremap [Window]e :JunkFile "}}} " e: Change basic commands "{{{ " The prefix key. nnoremap [Alt] xnoremap [Alt] nmap e [Alt] xmap e [Alt] " Indent paste. nnoremap [Alt]p opm``[=`]``^ xnoremap [Alt]p opm``[=`]``^ nnoremap [Alt]P OPm``[=`]``^ xnoremap [Alt]P OPm``[=`]``^ " Insert blank line. nnoremap [Alt]o o nnoremap [Alt]O O " Yank to end line. nmap [Alt]y y$ nmap Y y$ nnoremap x "_x " Useless commands nnoremap [Alt]; ; nnoremap [Alt], , "}}} " q: Quickfix "{{{ " The prefix key. nnoremap [Quickfix] nmap q [Quickfix] " Disable Ex-mode. nnoremap Q q " Toggle quickfix window. nnoremap [Quickfix] \ :call toggle_quickfix_window() function! s:toggle_quickfix_window() let _ = winnr('$') cclose if _ == winnr('$') copen setlocal nowrap setlocal whichwrap=b,s endif endfunction "}}} " Jump mark can restore column."{{{ nnoremap \ ` " Useless command. nnoremap M m "}}} " Smart , . nnoremap nnoremap " Disable ZZ. nnoremap ZZ " Like gv, but select the last changed text. nnoremap gc `[v`] " Specify the last changed text as {motion}. vnoremap gc :normal gc onoremap gc :normal gc " Auto escape / and ? in search command. cnoremap / getcmdtype() == '/' ? '\/' : '/' " Smart }."{{{ nnoremap } :call ForwardParagraph() onoremap } :call ForwardParagraph() xnoremap } :call ForwardParagraph()mzgv`z function! ForwardParagraph() let cnt = v:count ? v:count : 1 let i = 0 while i < cnt if !search('^\s*\n.*\S','W') normal! G$ return endif let i = i + 1 endwhile endfunction "}}} " Smart home and smart end."{{{ nnoremap gh :call SmartHome("n") nnoremap gl :call SmartEnd("n") xnoremap gh :call SmartHome("v") xnoremap gl :call SmartEnd("v") " Smart home function"{{{ function! SmartHome(mode) let curcol = col('.') if &wrap normal! g^ else normal! ^ endif if col('.') == curcol if &wrap normal! g0 else normal! 0 endif endif if a:mode == "v" normal! msgv`s endif return "" endfunction"}}} " Smart end function"{{{ function! SmartEnd(mode) let curcol = col('.') let lastcol = a:mode ==# 'i' ? col('$') : col('$') - 1 " Gravitate towards ending for wrapped lines if curcol < lastcol - 1 call cursor(0, curcol + 1) endif if curcol < lastcol if &wrap normal! g$ else normal! $ endif else normal! g_ endif " Correct edit mode cursor position, put after current character if a:mode == "i" call cursor(0, col(".") + 1) endif if a:mode == "v" normal! msgv`s endif return "" endfunction "}}} "}}} " Jump to a line and the line of before and after of the same indent."{{{ " Useful for Python. nnoremap g{ :call search('^' . \ matchstr(getline(line('.') + 1), '\(\s*\)') .'\S', 'b')^ nnoremap g} :call search('^' . \ matchstr(getline(line('.')), '\(\s*\)') .'\S')^ "}}} " Select rectangle. xnoremap r " Select until end of current line in visual mode. xnoremap v $h " Paste next line. nnoremap gp op^ nnoremap gP OP^ xnoremap gp op^ xnoremap gP OP^ " Redraw. nnoremap :redraw! " Folding."{{{ " If press h on head, fold close. "nnoremap h col('.') == 1 && foldlevel(line('.')) > 0 ? 'zc' : 'h' " If press l on fold, fold open. nnoremap l foldclosed(line('.')) != -1 ? 'zo0' : 'l' " If press h on head, range fold close. "xnoremap h col('.') == 1 && foldlevel(line('.')) > 0 ? 'zcgv' : 'h' " If press l on fold, range fold open. xnoremap l foldclosed(line('.')) != -1 ? 'zogv0' : 'l' noremap [Space]j zj noremap [Space]k zk noremap [Space]h zc noremap [Space]l zo noremap [Space]a za noremap [Space]m zM noremap [Space]i zMzv noremap [Space]rr zR noremap [Space]f zf noremap [Space]d zd noremap [Space]u :Unite outline:foldings noremap [Space]gg :echo FoldCCnavi() "}}} " Substitute. xnoremap s :s//g " Sticky shift in English keyboard."{{{ " Sticky key. inoremap ; sticky_func() cnoremap ; sticky_func() snoremap ; sticky_func() function! s:sticky_func() let sticky_table = { \',' : '<', '.' : '>', '/' : '?', \'1' : '!', '2' : '@', '3' : '#', '4' : '$', '5' : '%', \'6' : '^', '7' : '&', '8' : '*', '9' : '(', '0' : ')', '-' : '_', '=' : '+', \';' : ':', '[' : '{', ']' : '}', '`' : '~', "'" : "\"", '\' : '|', \} let special_table = { \"\" : "\", "\" : ';', "\" : ";\" \} if mode() !~# '^c' echo 'Input sticky key: ' endif let char = '' while char == '' let char = nr2char(getchar()) endwhile if char =~ '\l' return toupper(char) elseif has_key(sticky_table, char) return sticky_table[char] elseif has_key(special_table, char) return special_table[char] else return '' endif endfunction "}}} " Easy escape."{{{ inoremap jj " inoremap j getline('.')[col('.') - 2] ==# 'j' ? "\\" : 'j' cnoremap j getcmdline()[getcmdpos()-2] ==# 'j' ? "\\" : 'j' onoremap jj inoremap j j onoremap j j "}}} " Execute countable 'n.'. " EXAMPLE: 3@n let @n='n.' " a>, i], etc... "{{{ " onoremap aa a> xnoremap aa a> onoremap ia i> xnoremap ia i> " [rectangle] onoremap ar a] xnoremap ar a] onoremap ir i] xnoremap ir i] " 'quote' onoremap aq a' xnoremap aq a' onoremap iq i' xnoremap iq i' " "double quote" onoremap ad a" xnoremap ad a" onoremap id i" xnoremap id i" "}}} " Move to top/center/bottom. noremap zz (winline() == (winheight(0)+1)/ 2) ? \ 'zt' : (winline() == 1)? 'zb' : 'zz' " Capitalize. nnoremap gu gUiw`] inoremap gUiw`]a " Clear highlight. nnoremap :nohlsearch " operator-html-escape.vim nmap h (operator-html-escape) xmap h (operator-html-escape) " Easily macro. nnoremap @@ @a " Improved visual selection.{{{ " http://labs.timedia.co.jp/2012/10/vim-more-useful-blockwise-insertion.html xnoremap I force_blockwise_visual('I') xnoremap A force_blockwise_visual('A') function! s:force_blockwise_visual(next_key) "{{{ if mode() ==# 'v' return "\" . a:next_key elseif mode() ==# 'V' return "\0o$" . a:next_key else " mode() ==# "\" return a:next_key endif endfunction}}} "}}} " Improved increment. nmap (increment) nmap (decrement) nnoremap (increment) :AddNumbers 1 nnoremap (decrement) :AddNumbers -1 command! -range -nargs=1 AddNumbers \ call s:add_numbers((-+1) * eval()) function! s:add_numbers(num) let prev_line = getline('.')[: col('.')-1] let next_line = getline('.')[col('.') :] let prev_num = matchstr(prev_line, '\d\+$') if prev_num != '' let next_num = matchstr(next_line, '^\d\+') let new_line = prev_line[: -len(prev_num)-1] . \ printf('%0'.len(prev_num).'d', \ max([0, prev_num . next_num + a:num])) . next_line[len(next_num):] else let new_line = prev_line . substitute(next_line, '\d\+', \ "\\=printf('%0'.len(submatch(0)).'d', \ max([0, submatch(0) + a:num]))", '') endif if getline('.') !=# new_line call setline('.', new_line) endif endfunction "}}} "--------------------------------------------------------------------------- " Commands:"{{{ " " Toggle options. "{{{ function! ToggleOption(option_name) execute 'setlocal' a:option_name.'!' execute 'setlocal' a:option_name.'?' endfunction "}}} " Toggle variables. "{{{ function! ToggleVariable(variable_name) if eval(a:variable_name) execute 'let' a:variable_name.' = 0' else execute 'let' a:variable_name.' = 1' endif echo printf('%s = %s', a:variable_name, eval(a:variable_name)) endfunction "}}} " Display diff with the file. command! -nargs=1 -complete=file Diff vertical diffsplit " Display diff from last save. command! DiffOrig vert new | setlocal bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis " Disable diff mode. command! -nargs=0 Undiff setlocal nodiff noscrollbind wrap " Open junk file."{{{ command! -nargs=0 JunkFile call s:open_junk_file() function! s:open_junk_file() let junk_dir = $HOME . '/.vim_junk'. strftime('/%Y/%m') if !isdirectory(junk_dir) call mkdir(junk_dir, 'p') endif let filename = input('Junk Code: ', junk_dir.strftime('/%Y-%m-%d-%H%M%S.')) if filename != '' execute 'edit ' . filename endif endfunction"}}} " :HighlightWith {filetype} ['a 'b] XXX: Don't work in some case."{{{ command! -nargs=+ -range=% HighlightWith ,call s:highlight_with() " xnoremap [Space]h q:HighlightWith function! s:highlight_with(args) range if a:firstline == 1 && a:lastline == line('$') return endif let c = get(b:, 'highlight_count', 0) let ft = matchstr(a:args, '^\w\+') if globpath(&rtp, 'syntax/' . ft . '.vim') == '' return endif unlet! b:current_syntax let save_isk= &l:isk " For scheme. execute printf('syntax include @highlightWith%d syntax/%s.vim', \ c, ft) let &l:isk= save_isk execute printf('syntax region highlightWith%d start=/\%%%dl/ end=/\%%%dl$/ ' \ . 'contains=@highlightWith%d', \ c, a:firstline, a:lastline, c) let b:highlight_count = c + 1 endfunction"}}} " For git update in current directory. command! GitPullAll call s:git_pull_all() function! s:git_pull_all() let current_dir = getcwd() let cnt = 1 let dirs = map(split(glob('*/.git'), '\n'), 'fnamemodify(v:val, ":p:h:h")') let max = len(dirs) for dir in filter(dirs, " \ glob(v:val.'/*/*.vim') != '' || \ glob(v:val.'/*/*/*.vim') != '' || \ glob(v:val.'/*/*/*/*.vim') != ''") lcd `=dir` redraw echo printf('%d/%d git pull in %s', cnt, max, dir) let output = vimproc#system('git pull') if vimproc#get_last_status() echohl WarningMsg | echomsg output | echohl None endif echo '' let cnt += 1 endfor echo 'Done!' lcd `=current_dir` endfunction "}}} "--------------------------------------------------------------------------- " Functions:"{{{ " function! SnipMid(str, len, mask) "{{{ if a:len >= len(a:str) return a:str elseif a:len <= len(a:mask) return a:mask endif let len_head = (a:len - len(a:mask)) / 2 let len_tail = a:len - len(a:mask) - len_head return (len_head > 0 ? a:str[: len_head - 1] : '') \ . a:mask . (len_tail > 0 ? a:str[-len_tail :] : '') endfunction"}}} "}}} "--------------------------------------------------------------------------- " Platform depends:"{{{ " if s:is_windows " For Windows"{{{ " In Windows, can't find exe, when $PATH isn't contained $VIM. if $PATH !~? '\(^\|;\)' . escape($VIM, '\\') . '\(;\|$\)' let $PATH = $VIM . ';' . $PATH endif " Shell settings. " Use NYAOS. "set shell=nyaos.exe "set shellcmdflag=-e "set shellpipe=\|&\ tee "set shellredir=>%s\ 2>&1 "set shellxquote=\" " Use bash. "set shell=bash.exe "set shellcmdflag=-c "set shellpipe=2>&1\|\ tee "set shellredir=>%s\ 2>&1 "set shellxquote=\" " Change colorscheme. " Don't override colorscheme. if !exists('g:colors_name') && !has('gui_running') colorscheme darkblue endif " Disable error messages. let g:CSApprox_verbose_level = 0 " Popup color. hi Pmenu ctermbg=8 hi PmenuSel ctermbg=1 hi PmenuSbar ctermbg=0 "}}} else " For Linux"{{{ if exists('$WINDIR') " Cygwin. " Use bash. set shell=bash else " Use zsh. set shell=zsh endif " Set path. let $PATH = expand('~/bin').':/usr/local/bin/:'.$PATH " For non GVim. if !has('gui_running') " Enable 256 color terminal. if !exists('$TMUX') set t_Co=256 " For screen."{{{ if &term =~ '^screen' augroup MyAutoCmd " Show filename on screen statusline. " But invalid 'another' screen buffer. autocmd BufEnter * if $WINDOW != 0 && \ bufname("") !~ "[A-Za-z0-9\]*://" \ | silent! exe '!echo -n "kv:%:t\\"' | endif " When 'mouse' isn't empty, Vim will freeze. Why? autocmd VimLeave * :set mouse= augroup END " For Vim inside screen. set ttymouse=xterm2 endif " For prevent bug. autocmd MyAutoCmd VimLeave * set term=screen "}}} endif if has('gui') " Use CSApprox.vim NeoBundleSource csapprox " Convert colorscheme in Konsole. let g:CSApprox_konsole = 1 let g:CSApprox_attr_map = { \ 'bold' : 'bold', \ 'italic' : '', 'sp' : '' \ } if !exists('g:colors_name') colorscheme candy endif else " Use guicolorscheme.vim NeoBundleSource vim-guicolorscheme autocmd MyAutoCmd VimEnter,BufAdd * \ if !exists('g:colors_name') | GuiColorScheme candy " Disable error messages. let g:CSApprox_verbose_level = 0 endif " Change cursor shape. if &term =~ "xterm" let &t_SI = "\]12;lightgreen\x7" let &t_EI = "\]12;white\x7" endif endif "}}} endif "}}} "--------------------------------------------------------------------------- " Others:"{{{ " " Enable mouse support. set mouse=a " If true Vim master, use English help file. set helplang& helplang=en,ja " Default home directory. let t:cwd = getcwd() "}}} if !has('vim_starting') call neobundle#call_hook('on_source') endif set secure