.vimrcさらす
混沌としてたので
纏めようとしたら
更に混沌としてきた結果がこれだよ
" ============================================================= " ショートカット " ============================================================= " {{{ " Tabで自動保管 inoremap <tab> <c-r>=InsertTabWrapper()<cr> " タブ操作用(Firefox風) "map <C-S-tab> :tabprevious<cr> "map <C-tab> :tabnext<cr> map tr :tabprevious<cr> map te :tabnext<cr> map <C-w> :tabclose<cr> "nmap <C-S-tab> :tabprevious<cr> "nmap <C-tab> :tabnext<cr> nmap tr :tabprevious<cr> nmap te :tabnext<cr> nmap <C-t> :tabnew<cr> "imap <C-S-tab> <ESC>:tabprevious<cr>i "imap <C-tab> <ESC>:tabnext<cr>i imap tr <ESC>:tabprevious<cr>i imap te <ESC>:tabnext<cr>i imap <C-t> <ESC>:tabnew<cr> " エスケープのためのショートカット "nnoremap q <ESC><cr> " ヘルプ見るためのショートカット nnoremap <C-h> :<C-u>help<Space> " 最後に変更されたテキストを選択する nnoremap gc `[v`] " クリップボードから貼り付ける "nnoremap <C-p> "+gP " カーソル行をハイライト nnoremap <silent> ,ha :HighlightCurrentLine Search<cr> nnoremap <silent> ,hb :HighlightCurrentLine DiffAdd<cr> nnoremap <silent> ,hc :HighlightCurrentLine Error<cr> nnoremap <silent> ,H :UnHighlightCurrentLine<cr> " ビジュアルモードで選択したテキストを検索 vnoremap * y/<C-r>0<CR> " Visualモードで選択した範囲を(コメントアウト|コメント削除) vmap ,# :s/^/#/<CR>:nohlsearch<CR> vmap ,c :s/^\/\/\\|^--\\|^> \\|^[#"%!;]//<CR>:nohlsearch<CR> " }}} " ============================================================= " 初期設定 " ============================================================= " {{{ syntax on filetype on filetype indent on filetype plugin on " インデント方式 set shiftwidth=2 set smarttab " インクリメンタル検索 set incsearch set hlsearch " Tabによるインデント回避 set expandtab "カーソルのある行番号の表示 set ruler " テーマ設定 colorscheme desert " 保管候補のポップアップの色設定 " popup color for incr-search " hi Pmenu guibg=#666666 " hi PmenuSel guibg=#8cd0d3 guifg=#666666 " hi PmenuSbar guibg=#333333 " タブ系の設定 set showtabline=2 " タブ色設定 hi TabLine term=reverse cterm=reverse ctermfg=white ctermbg=black hi TabLineSel term=bold cterm=bold,underline ctermfg=5 hi TabLineFill term=reverse cterm=reverse ctermfg=white ctermbg=black " 行番号表示 set number " ヤンクしたテキストを無名レジスタだけでなく、*レジスタにも入るようにする "set clipboard+=unnamed " 折り返さない set nowrap " 改行文字とタブ文字の色設定(NonTextが改行、SpecialKeyがタブ) "hi NonText guibg=NONE guifg=Gray40 "hi SpecialKey guibg=NONE guifg=Gray40 " 文字コード表示 "set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P " for windows key-map set backspace=2 " バックアップとか自分でしろ set nobackup " 対応する括弧の表示 set showmatch " はてダ操作用 set runtimepath+=/usr/share/vim/hatena let g:hatena_user='rin1024' " }}} " ============================================================= " ユーティリティ " ============================================================= " {{{ " ----------------------------------- " 文字コードの自動認識 " ----------------------------------- 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' " iconvがeucJP-msに対応しているかをチェック 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' " iconvがJISX0213に対応しているかをチェック 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 " fileencodingsを構築 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 " 日本語を含まない場合は fileencoding に encoding を使うようにする if has('autocmd') function! AU_ReCheck_FENC() if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0 let &fileencoding=&encoding endif endfunction autocmd BufReadPost * call AU_ReCheck_FENC() endif " 改行コードの自動認識 set fileformats=unix,dos,mac " □とか○の文字があってもカーソル位置がずれないようにする if exists('&ambiwidth') set ambiwidth=double endif " ----------------------------------- " <TAB>で補完 by cho45 " ----------------------------------- " Autocompletion using the TAB key " This function determines, wether we are on the start of the line text (then tab indents) or " if we want to try autocompletion function! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\<TAB>" else if pumvisible() return "\<C-N>" else return "\<C-N>\<C-P>" end endif endfunction " Remap the tab key to select action with InsertTabWrapper " Autocompletion using the TAB key " ----------------------------------- " 辞書の設定 " autocmdは自動実行されるコマンド " ----------------------------------- autocmd FileType perl :set dictionary=/usr/share/vim/vim70/syntax/perl.vim autocmd FileType ruby :set dictionary=/usr/share/vim/vim70/syntax/ruby.vim autocmd FileType php :set dictionary=/usr/share/vim/vim70/syntax/php.vim autocmd FileType java :set dictionary=/usr/share/vim/vim70/syntax/java.vim autocmd FileType html :set dictionary=/usr/share/vim/vim70/syntax/html.vim autocmd FileType javascript :set dictionary=/usr/share/vim/vim70/syntax/javascript.vim " ----------------------------------- " シンタックスのチェック " ----------------------------------- "autocmd BufWrite *.rb !ruby -c % "autocmd BufWrite *.pl !perl -c % " ----------------------------------- " 自動補完用 " ----------------------------------- " 補完候補表示中に改行したら決定+改行 " inoremap <expr> <CR> pumvisible() ? "\<C-Y>\<CR>" : "\<CR>" " Set skip input time. let g:NeoComplCache_SkipInputTime = '0.2' " ----------------------------------- " カーソルがある行をハイライト " ----------------------------------- command! -nargs=1 HighlightCurrentLine execute 'match <args> /<bslash>%'.line('.').'l/' command! -nargs=0 UnHighlightCurrentLine match " }}}