"*** myvimrc *** " vim: set fdm=marker: "**** option {{{1 filetype plugin indent on set ambiwidth=double set autochdir set autoindent set autoread set background=dark set backspace=2 set clipboard=unnamed,unnamedplus,exclude:cons\|linux set cmdheight=2 set complete=.,w set completefunc=GoogleComplete set cryptmethod=blowfish2 set diffopt=filler,vertical set expandtab set fileencodings=ucs-bom,utf-8,sjis,euc-jp set fileformats=unix,dos,mac set foldcolumn=2 set foldopen=mark,percent,quickfix,tag set formatoptions=tcqmM set grepformat=%f:%l:%m,%f:%l%m,%f\ \ %l%m,%f set grepprg=ack\ -il\ $*\ /dev/null set history=5000 set hlsearch set ignorecase set incsearch set laststatus=2 set listchars=tab:>-,trail:- set matchtime=1 set modeline set modelines=10 set nobackup set noendofline set noequalalways set noerrorbells set noswapfile set nowrap set nowrapscan set nrformats=hex set number set pastetoggle= set ruler set selection=inclusive set selectmode="" set shiftwidth=4 set showcmd set showmatch set showtabline=2 set smartcase set spellcapcheck= set spelllang=en_us set statusline=%<%f\ %2*%{&mod&&&bt!=#'terminal'?'[+]':''}%0*%{&ro?'[RO]':''}%h%w%=%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}\ %2*%y%0*%6l,%c%V%1*%8P set t_vb= set tabstop=4 set tags=tags; set titlelen=100 set titlestring=%t\ (%<%{expand(\"%:p:h\")})\ \-\ %{v:servername}\ %{v:version} set undodir=~/.vim/undo/ set undofile set viewdir=~/.vim/view/ set viewoptions=folds,cursor,options set visualbell set whichwrap+=[ set whichwrap+=] set wildmenu set wildmode=list:longest,full syntax on "}}} "**** map {{{1 cnoreabbrev Y Ygrep cnoreabbrev t tabe cnoremap cnoremap cnoremap cnoremap imap (neosnippet_expand_or_jump) inoremap inoremap jj nnoremap + , nnoremap ,d :DeleteComment nnoremap ,e :Imadesyo nnoremap / :set ims=0/ nnoremap gT nnoremap :bn nnoremap :bp nnoremap i nnoremap :noh nnoremap :tab :h nnoremap :WindowSizeToggle nnoremap :call SpellToggle() nnoremap zh nnoremap zl nnoremap gt nnoremap Y y$ nnoremap co :copen nnoremap s nnoremap sb :Unite buffer nnoremap sc :call CdPaste() nnoremap se :call MyNeoSnippetEdit() nnoremap sf :Unite file_rec nnoremap sg :Unite line nnoremap sh :belowright :terminal ++close nnoremap sn :NERDTreeToggle nnoremap sp :Unite neosnippet nnoremap sv :call ToggleVe() nnoremap x "_x smap (neosnippet_expand_or_jump) vnoremap * y/" vnoremap s !ore_escape_filename.pl xmap (neosnippet_expand_target) " terminal mode if has('terminal') tnoremap "" tnoremap N endif "}}} "**** command {{{1 augroup PasteOff autocmd! autocmd InsertLeave * set nopaste augroup END augroup SaveView autocmd! autocmd BufReadPost * silent! loadview autocmd BufWritePost * call MkView() augroup END augroup Quickfix autocmd! autocmd Filetype qf nnoremap q :q autocmd QuickfixCmdPost make,grep,grepadd,vimgrep copen augroup END command! -nargs=* Ygrep call Ygrep() command! -nargs=0 -range HonyakuEJ ,!trans -no-ansi -from en -to ja -show-original=n -show-languages=n -show-prompt-message=n -show-alternatives=n -show-translation-phonetics=n command! -nargs=0 -range HonyakuJE ,!trans -no-ansi -from ja -to en -show-original=n -show-languages=n -show-prompt-message=n -show-alternatives=n -show-translation-phonetics=n command! -nargs=0 B e ~/.bashrc command! -nargs=0 BookmarkOpen tabe ~/.NERDTreeBookmarks command! -nargs=0 CdCurrent cd %:p:h command! -nargs=0 ClearHistory call ClearHistory() command! -nargs=0 CopyPaste setlocal nonu foldcolumn=0 command! -nargs=0 DeleteComment g/^\s*#\|^\s*$/d command! -nargs=0 Diffoff diffoff! | set fdc=2 command! -nargs=0 Eiwa call Trans() command! -nargs=0 Kakkofold call Kakkofold() command! -nargs=0 M e ~/memo.md command! -nargs=0 P tabe ~/wiki/life/passwd.md command! -nargs=0 Prettier w | call system("prettier --write " . expand("%")) | e command! -nargs=0 RjcolorToggle call RjcolorToggle() command! -nargs=0 SSH e ~/.ssh/config command! -nargs=0 Spell call SpellToggle() command! -nargs=0 T tabe % command! -nargs=0 Tabnasi setlocal expandtab | setlocal list | retab command! -nargs=0 V tabe ~/.vim/pack/plugins/start/myvimrc/plugin/myvimrc.vim command! -nargs=0 VL tabe $MYVIMRC command! -nargs=0 W call WikiOpen() command! -nargs=0 WindowSizeToggle call WindowSizeToggle() command! -nargs=1 -complete=file VDsplit vertical diffsplit "}}} "**** function {{{1 function! Kakkofold() "{{{2 setlocal foldmarker={,} setlocal fdm=marker normal zM setlocal fdm=manual setlocal foldmarker={{{,}}} endfunction "}}} function! ClearHistory() "{{{2 let old_undolevels = &undolevels set undolevels=-1 exe "normal a \\" let &undolevels = old_undolevels unlet old_undolevels endfunction "}}} function! Ygrep(...) "{{{2 let dir = "" let exp = "" if !exists("a:1") let exp = @/ else let exp = a:1 endif if !exists("a:2") "let dir = "%:p:h" let dir = "." endif let index = 2 while index <= a:0 let dir = dir . " " . a:{index} let index = index + 1 endwhile execute 'silent grep! ' . exp . " " . dir execute 'redr!' endfunction "}}} function! SpellToggle() "{{{2 setlocal spell! if exists("g:syntax_on") syntax off else syntax on endif setlocal spell? endfunction "}}} function! WindowSizeToggle() "{{{2 if hasmapto('<','n') nunmap nunmap nunmap nunmap else nnoremap < nnoremap - nnoremap + nnoremap > endif endfunction "}}} WindowSizeToggle function! RjcolorToggle() "{{{2 if hasmapto('RjcolorNext','n') nunmap nunmap else nnoremap :RjcolorNext nnoremap :RjcolorBack endif endfunction "}}} function! GoogleComplete(findstart, base) "{{{2 if a:findstart let line = getline('.') let start = col('.') - 1 while start > 0 && line[start - 1] =~ '\S' let start -= 1 endwhile return start else let ret = system('curl -s -G' \ . ' --data-urlencode "q=' . a:base . '"' \ . ' --data-urlencode "client=firefox"' \ . ' --data-urlencode "hl=ja"' \ . ' --data-urlencode "ie=utf8"' \ . ' --data-urlencode "oe=utf8"' \ . ' "http://suggestqueries.google.com/complete/search"' \) let res = split(substitute(ret,'\[\|\]\|"',"","g"),",") return res endif endfunction "}}} function! MkView() "{{{2 if &fdm != "diff" mkview endif endfunction "}}} function! Trans() "{{{2 let l:search_word = expand("") let l:result = system("trans -no-ansi -from en -to ja -show-original=n -show-languages=n -show-prompt-message=n -show-alternatives=n -show-translation-phonetics=n -show-original-phonetics=n -show-dictionary=n " . l:search_word) echo l:result endfunction "}}} function! MyNeoSnippetEdit() "{{{2 execute "NeoSnippetEdit -split ".&ft endfunction "}}} function! WikiOpen() "{{{2 let wiki = expand("~/") . "wiki/README.md" if filereadable(wiki) e ~/wiki/README.md CdCurrent else echomsg "wikiがない" endif endfunction "}}} function! CdPaste() "{{{2 exe "cd " . @" endfunction "}}} function! ToggleVe() "{{{2 if &ve == 'all' set ve= else set ve=all endif endfunction "}}} "}}}