" " " MEMO {{{ " :help internal-variables {{{ "+----+-------------------+---------------------------------------------+ "| b: | buffer-variable | Local to the current buffer. | "| w: | window-variable | Local to the current window. | "| t: | tabpage-variable | Local to the current tab page. | "| g: | global-variable | Global. | "| l: | local-variable | Local to a function. | "| s: | script-variable | Local to a :source'ed Vim script. | "| a: | function-argument | Function argument (only inside a function). | "| v: | vim-variable | Global, predefined by Vim. | "+----+-------------------+---------------------------------------------+ "}}} " :help map {{{ "+----------------------------------------------+--------------------------------------------------------------------------------+ "|commands: |modes: | "| Variables | Constants | Unset | Destroy | Normal | Visual | Select | Operator-pending | Insert | Command-line | Lang-Arg | "| :map | :noremap | :unmap | :mapclear | yes | yes | yes | yes | - | - | - | "| :nmap | :nnoremap | :nunmap | :nmapclear | yes | - | - | - | - | - | - | "| :vmap | :vnoremap | :vunmap | :vmapclear | - | yes | yes | - | - | - | - | "| :omap | :onoremap | :ounmap | :omapclear | - | - | - | yes | - | - | - | "| :xmap | :xnoremap | :xunmap | :xmapclear | - | yes | - | - | - | - | - | "| :smap | :snoremap | :sunmap | :smapclear | - | - | yes | - | - | - | - | "| :map! | :noremap! | :unmap! | :mapclear! | - | - | - | - | yes | yes | - | "| :imap | :inoremap | :iunmap | :imapclear | - | - | - | - | yes | - | - | "| :cmap | :cnoremap | :cunmap | :cmapclear | - | - | - | - | - | yes | - | "| :lmap | :lnoremap | :lunmap | :lmapclear | - | - | - | - | yes* | yes* | yes* | "+-----------+-----------+---------+------------+--------+--------+--------+------------------+--------+--------------+----------+ "}}} "}}} " " " Variables {{{ let s:envHome = ! exists('s:envHome') ? $HOME : s:envHome let s:date = ! exists('s:date') ? strftime('%Y%m%d%H%M%S', localtime()) : s:date let s:lineUpdate = ! exists('s:lineUpdate') ? 0 : s:lineUpdate "}}} " " " Common {{{ " Zun wiki http://www.kawaz.jp/pukiwiki/?vim#cb691f26 {{{ set encoding=utf-8 fileencoding=utf-8 fileformats=unix,dos,mac let s:enc_euc = 'euc-jp' let s:enc_jis = 'iso-2022-jp' if iconv("\x87\x64\x87\x6a", 'cp932', 'eucjp-ms') ==# "\xad\xc5\xad\xcb" let s:enc_euc = 'eucjp-ms' let s:enc_jis = 'iso-2022-jp-3' elseif iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb" let s:enc_euc = 'euc-jisx0213' let s:enc_jis = 'iso-2022-jp-3' endif let &fileencodings = &fileencodings .','. s:enc_jis .','. s:enc_euc .',cp932' unlet s:enc_euc unlet s:enc_jis "}}} scriptencoding utf-8 let g:mapleader = ',' augroup MyAutoCmd autocmd! augroup END function! s:KazuakiMAutoMkdir(dir) abort "{{{ if !isdirectory(a:dir) call mkdir(iconv(a:dir, &encoding, &termencoding), 'p') endif endfunction "}}} function! s:KazuakiMVimStart(backupDir, undoDir) abort "{{{ "Check 256KB file size. if getfsize(expand('%:p')) >= 262144 call kazuakim#Minimal() return 1 endif call s:KazuakiMAutoMkdir(a:backupDir.s:date) call s:KazuakiMAutoMkdir(a:undoDir. s:date) let &backupdir = a:backupDir.s:date let &undodir = a:undoDir. s:date return 0 endfunction "}}} if has('vim_starting') if has('win32') || has ('win64') set runtimepath^=$HOME/.vim runtimepath+=$HOME/.vim/after if s:KazuakiMVimStart('C:\temp\backup\', 'C:\temp\undo\') finish endif let s:osType = 'win' " vimproc.vim {{{ let g:vimproc#dll_path = s:envHome . '/.vim/bundle/vimproc.vim/lib/vimproc_win64.dll' let g:vimproc#download_windows_dll = 1 "}}} elseif has('macunix') if s:KazuakiMVimStart('/tmp/backup/', '/tmp/undo/') finish endif let s:osType = 'macunix' else if s:KazuakiMVimStart('/tmp/backup/', '/tmp/undo/') finish endif let s:osType = 'unix' endif endif function! s:KazuakiMCheckString() abort "{{{ let w:m1 = matchadd('KazuakiMCheckString', '\t\|\r\|\r\n\|\s\+$\| ') let w:m2 = matchadd('KazuakiMTodo', 'FIXME\|MEMO\|NOTE\|TODO\|XXX') endfunction "}}} function! s:KazuakiMBufEnter() abort "{{{ " Auto close VimDiff or primary NERDTree if winnr('$') is# 1 && (&l:diff || (exists('b:NERDTree') && b:NERDTree.isTabTree()) || &filetype is# 'quickrun') quit " Duplicate ban elseif v:servername is# 'GVIM1' setlocal viminfo= call remote_send('GVIM', ':tabnew '.expand('%:p').'') call remote_foreground('GVIM') quit elseif v:servername is# 'VIM1' setlocal viminfo= call remote_send('VIM', ':tabnew '.expand('%:p').'') call remote_foreground('VIM') quit endif " Move current file(/directory) path execute 'lcd '. fnameescape(expand('%:p:h')) " default filetype if &filetype is# '' || &filetype is# 'text' setlocal filetype=markdown endif " Forcibly update set formatoptions-=c formatoptions-=b formatoptions+=j formatoptions-=t formatoptions-=v textwidth=0 " Set StatusLine if &fileencoding is# 'utf-8' highlight StatusLine cterm=NONE gui=NONE ctermfg=Black guifg=Black ctermbg=Grey guibg=Grey else highlight StatusLine cterm=NONE gui=NONE ctermfg=Black guifg=Black ctermbg=Yellow guibg=Yellow endif endfunction "}}} function! s:KazuakiMBufReadPost() abort "{{{ " memory cursol if line("'\"") > 1 && line("'\"") <= line('$') execute "normal! g`\"" endif " Zun wiki http://www.kawaz.jp/pukiwiki/?vim#cb691f26 {{{ if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0 let &fileencoding = &encoding endif "}}} endfunction "}}} function! s:KazuakiMInsertLeave() abort "{{{ set nopaste if &l:diff diffupdate endif endfunction "}}} function! s:KazuakiMVimEnter() abort "{{{ " Forcibly update set ambiwidth=double showtabline=2 call s:KazuakiMCheckString() if &l:diff wincmd h endif endfunction "}}} function! s:KazuakiMWinEnter() abort "{{{ checktime call s:KazuakiMCheckString() endfunction "}}} autocmd MyAutoCmd BufEnter * call s:KazuakiMBufEnter() autocmd MyAutoCmd BufReadPost * call s:KazuakiMBufReadPost() autocmd MyAutoCmd CmdwinEnter * nmap :quit autocmd MyAutoCmd CmdwinLeave * nunmap autocmd MyAutoCmd FocusGained * checktime autocmd MyAutoCmd InsertLeave * call s:KazuakiMInsertLeave() autocmd MyAutoCmd QuickfixCmdPost *grep* cwindow autocmd MyAutoCmd QuickfixCmdPost * call kazuakim#QuickfixCmdPost() autocmd MyAutoCmd VimEnter * call s:KazuakiMVimEnter() autocmd MyAutoCmd WinEnter * call s:KazuakiMWinEnter() function! KazuakiMStatuslineSyntax() abort "{{{ let l:ret = qfstatusline#Update() if 0 < len(l:ret) if s:lineUpdate is# 0 highlight StatusLine cterm=NONE gui=NONE ctermfg=Black guifg=Black ctermbg=Magenta guibg=Magenta let s:lineUpdate = 1 endif elseif s:lineUpdate is# 1 highlight StatusLine cterm=NONE gui=NONE ctermfg=Black guifg=Black ctermbg=Grey guibg=Grey let s:lineUpdate = 0 endif return l:ret endfunction "}}} function! KazuakiMStatuslinePaste() abort "{{{ if &paste is# 1 return '(paste)' endif return '' endfunction "}}} " http://d.hatena.ne.jp/thinca/20111204/1322932585 function! s:KazuakiMTabpageLabelUpdate(tabNumber) abort "{{{ let l:highlight = a:tabNumber is# tabpagenr() ? '%#TabLineSel#' : '%#TabLine#' let l:bufnrs = tabpagebuflist(a:tabNumber) let l:bufnr = len(l:bufnrs) if l:bufnr is# 1 let l:bufnr = '' endif let l:modified = len(filter(copy(l:bufnrs), 'getbufvar(v:val, "&modified")')) ? '[+]' : '' return '%'. a:tabNumber .'T'. l:highlight . l:bufnr .' '. fnamemodify(bufname(l:bufnrs[tabpagewinnr(a:tabNumber) - 1]), ':t') .' '. l:modified . \ '%T%#TabLineFill#' endfunction "}}} function! KazuakiMTabLineUpdate() abort "{{{ return join(map(range(1, tabpagenr('$')), 's:KazuakiMTabpageLabelUpdate(v:val)'), '|') .'%#TabLineFill#%T%=%#TabLineSel# '. getcwd() .' ' endfunction "}}} " Basic set autoindent autoread set backspace=indent,eol,start backup set clipboard+=autoselect,unnamed cmdheight=1 concealcursor=i conceallevel=2 completeopt=longest,menu set diffopt=filler,context:5,iwhite,vertical display=lastline set expandtab set fillchars+=diff:* foldmethod=marker set grepformat=%f:%l:%m,%f:%l%m,%f\ \ %l%m guioptions+=M set helplang=ja hidden history=1000 hlsearch set ignorecase iminsert=0 imsearch=-1 incsearch set laststatus=2 lazyredraw set matchpairs+=<:> matchtime=1 mouse= set nobomb noequalalways noerrorbells nogdefault noimcmdline noimdisable noruler noswapfile notitle number set pumheight=8 set runtimepath+=$HOME/.vim/bundle/neobundle.vim set scrolloff=999 shellslash shiftwidth=4 shortmess+=a shortmess+=I showcmd showmatch smartcase smartindent smarttab softtabstop=4 switchbuf=usetab set tabline=%!KazuakiMTabLineUpdate() tabstop=4 titleold= ttyfast t_vb= set undofile updatecount=30 updatetime=1000 set viminfo='10,/100,:100,@100,c,f1,h,<100,s100,n~/.vim/viminfo/.viminfo virtualedit+=block visualbell set wildmenu wildmode=longest:full,full wrap wrapscan set grepprg=grep\ -rnIH\ --exclude-dir=.svn\ --exclude-dir=.git\ --exclude='*.json'\ --exclude='*.log'\ --exclude='*min.js'\ --exclude='*min.css' set wildignore+=*.bmp,*.gif,*.git,*.ico,*.jpeg,*.jpg,*.log,*.mp3,*.ogg,*.otf,*.pdf,*.png,*.qpf2,*.svn,*.ttf,*.wav,C,.DS_Store,.,.. set statusline=\ %t\ %{KazuakiMStatuslinePaste()}\ %m\ %r\ %h\ %w\ %q\ %{KazuakiMStatuslineSyntax()}%=%l/%L\ \|\ %Y\ \|\ %{&fileformat}\ \|\ %{&fileencoding}\ if &l:diff set cursorline else set nocursorline endif "set foldopen-=search "helptags $HOME/.vim/bundle/vimdoc-ja/doc " Color syntax enable colorscheme kazuakim " Mapping " ESC inoremap jk inoremap kj " Fold nnoremap zx :foldopen " Line noremap 0 $ noremap 1 ^ nnoremap Y y$ inoremap u inoremap u " Tag nnoremap gr gT " Window Size nnoremap [ws] nmap + +[ws] nmap - -[ws] nmap > >[ws] nmap < <[ws] nnoremap