" ____ " ,--, ,' , `. " ,--.'| ,-+-,.' _ | __ ,-. " .---.| |, ,-+-. ; , ||,' ,'/ /| " /. ./|`--'_ ,--.'|' | ||' | |' | ,---. " .-' . ' |,' ,'| | | ,', | |,| | ,'/ \ " /___/ \: |' | | | | / | |--' ' : / / / ' " . \ ' .| | : | : | | , | | ' . ' / " \ \ '' : |__ | : | |/ ; : | ' ; :__ " ___\ \ | | '.'|| | |`-' | , ; ' | '.'| " / .\\ \ |; : ;| ;/ ---' | : : " \ ; |'---" | , / '---' \ \ / " `--" ---`-' `----' " basic {{{ if &compatible set nocompatible " for gvim on windows endif set modeline set modelines=3 let g:vim_indent_cont = 4 if has('unix') set nofixendofline endif " }}} " encoding {{{ set encoding=utf-8 set fileencodings=utf-8,euc-jp,sjis,cp932,iso-2022-jp "set fileencoding=utf-8 "set fileencodings=utf-8,cp932 "if &encoding !=# 'utf-8' " set encoding=japan " set fileencoding=japan "endif "if has('iconv') " 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 " if &encoding ==# 'utf-8' " let s:fileencodings_default = &fileencodings " let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932' " let &fileencodings = &fileencodings .','. s:fileencodings_default " unlet s:fileencodings_default " else " let &fileencodings = &fileencodings .','. s:enc_jis " set fileencodings+=utf-8,ucs-2le,ucs-2 " if &encoding =~# '^\(euc-jp\|euc-jisx0213\|eucjp-ms\)$' " set fileencodings+=cp932 " set fileencodings-=euc-jp " set fileencodings-=euc-jisx0213 " set fileencodings-=eucjp-ms " let &encoding = s:enc_euc " let &fileencoding = s:enc_euc " else " let &fileencodings = &fileencodings .','. s:enc_euc " endif " endif " unlet s:enc_euc " unlet s:enc_jis "endif "if has('autocmd') " function! AU_ReCheck_FENC() " if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0 " let &fileencoding=&encoding " endif " endfunction " " augroup check_fenc " autocmd BufReadPost * call AU_ReCheck_FENC() " augroup END "endif scriptencoding utf-8 " }}} " color scheme {{{ syntax enable colorscheme desert " }}} " search {{{ set ignorecase set smartcase set wrapscan set hlsearch set incsearch cnoremap / getcmdtype() == '/' ? '\/' : '/' cnoremap ? getcmdtype() == '?' ? '\?' : '?' " }}} " paste {{{ set pastetoggle= " }}} " visual {{{ set showtabline=2 set tabstop=4 set expandtab set autoindent set backspace=indent,eol,start set showmatch set wildmenu set formatoptions+=mM set nonumber set ruler set list set listchars=tab:>-,trail:_,eol:\ ,extends:>,precedes:> set wrap set cmdheight=2 set showcmd set smartindent set smarttab set shiftwidth=4 set noequalalways set cursorline "set cursorcolumn augroup cch autocmd! cch autocmd WinLeave * set nocursorline autocmd WinEnter,BufRead * set cursorline augroup END :hi clear CursorLine :hi CursorLine gui=underline highlight CursorLine ctermbg=black guibg=black " }}} " fold {{{ set foldmethod=marker set foldlevel=2 " }}} " buffer {{{ set hidden set autoread " }}} " system {{{ let mapleader=',' let maplocalleader="\\" " }}} " spell {{{ set spelllang=en,cjk " スペルチェック時に日本語は除外する nnoremap sss :setlocal spell! " }}} " mapping {{{ nnoremap cnoremap inoremap inoremap jj vnoremap nnoremap ; : nnoremap : ; nnoremap > % nnoremap < % cnoremap cnoremap cnoremap inoremap () () inoremap [] [] inoremap {} {} inoremap "" "" inoremap '' '' nnoremap :nohlsearch nnoremap :nohlsearch nnoremap :Ex nnoremap g nnoremap za if has('win32') nnoremap za endif nnoremap QQ :bd! " }}} " copy to clipboard {{{ if has('win32') vnoremap "*y endif if system('uname') ==# "Darwin\n" set clipboard=unnamed,autoselect endif " paste from clipboard nnoremap i+l cnoremap + inoremap + " }}} " tab {{{ nnoremap tn :tabnew nnoremap th :tabp nnoremap tl :tabn nnoremap t0 :tabfirst nnoremap t$ :tablast " }}} " command {{{ command! ToUTF8 set fileencoding=utf-8 command! ToEUC set fileencoding=euc-jp command! ToSJIS set fileencoding=sjis command! ToUNIX set fileformat=unix " }}} " auto command {{{ aug MyAutoCompletion au! " XML, HTML補完 autocmd FileType eruby,html,xml,markdown setlocal omnifunc=htmlcomplete#CompleteTags autocmd FileType xml,html inoremap aug END aug MyAutoOpenCWindow au! autocmd QuickFixCmdPost *grep* cwindow aug END if $TMUX !=# '' augroup titlesettings autocmd! autocmd BufEnter * call system("tmux rename-window " . "'[vim] " . expand("%:t") . "'") autocmd VimLeave * call system("tmux rename-window zsh") autocmd BufEnter * let &titlestring = ' ' . expand("%:t") augroup END endif " }}} " status line {{{ set statusline=[%n]\ " バッファ番号 set statusline+=%f\ " 相対ファイル名 set statusline+=%m\ " バッファ状態[+] set statusline+=%r " 読み取り専用フラグ set statusline+=%<%= " 右寄せ set statusline+=%{'['.(&fenc!=''?&fenc:'?').'-'.&ff.']'}\ " フォーマット&文字コード set statusline+=%y\ " タイプ set statusline+=%4l,%2c\ " 行、列 set statusline+=%3p%%\ " 何% set laststatus=2 " }}} " omni completion {{{ function! InsertTabWrapper(type) let col = col('.') - 1 "omni補完の場合、omini以外にも上下左右の移動もする if a:type ==# 'omni' if pumvisible() return "\" endif if !col || getline('.')[col - 1] !~# '\k\|<\|/' return "\" elseif exists('&omnifunc') && &omnifunc ==# '' return "\" else return "\\" endif "keywordの場合、該当のとき以外は何もしない else if pumvisible() || !col || getline('.')[col - 1] !~# '\k\|<\|/' return '' else return "\\" endif endif endfunction inoremap =InsertTabWrapper('omni')=InsertTabWrapper('keyword') " }}} " matchit {{{ source $VIMRUNTIME/macros/matchit.vim let b:match_ignorecase = 1 " }}} set wildignore=*.o,*.bk,*.org,*.exe,*.so \,*.dll,*.swp,*.zip,*.pyc,.gitkeep " load conf.d {{{ set runtimepath+=$HOME/.vim/ runtime! conf.d/*.vim " }}} " vim:fdl=0