現在の.vimrc、ほとんどがオプションの設定だけで凝ったことはしていない。ここ数年ぐらいは全然編集していない気がするし。
でも最近は色々と考え方が変わってきたので、もっと凝ったことをしようと思っている。Normal modeで<Space>は全然使わないので、まずはこれをベースに色々と弄ってみるかな。
という訳で、今年の抱負は「Vimを極める」ことにする。
set nocompatible
set encoding=japan
if has('iconv')
let s:enc_euc = 'euc-jp'
let s:enc_jis = 'iso-2022-jp'
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
let &fileencodings = &fileencodings . ',' . s:enc_jis
set fileencodings+=utf-8,ucs-2le,ucs-2
if &encoding =~# '^euc-\%(jp\|jisx0213\)$'
set fileencodings+=cp932
let &encoding = s:enc_euc
else
let &fileencodings = &fileencodings . ',' . s:enc_euc
endif
unlet s:enc_euc
unlet s:enc_jis
endif
if 1 < &t_Co && has('syntax')
syntax enable
colorscheme default
set background=dark
endif
set autoindent
set backspace=indent,eol,start
set backup
set backupcopy&
set backupdir=.,~/tmp
set directory=.,~/tmp
set noequalalways
set history=100
set hlsearch
set incsearch
set mouse=
set ruler
set showcmd
set showmode
set smartindent
set updatetime=60000
set title
set titlestring=vi:\ %f\ %h%r%m
set viminfo=<50,'10,h,r/a,n~/.viminfo
filetype plugin indent on
function ToggleOption(opt_name)
execute "if &" . a:opt_name . "\n"
\ . " let &" . a:opt_name . " = 0\n"
\ . " echo '" . a:opt_name . " off'\n"
\ . "else\n"
\ . " let &" . a:opt_name . " = 1\n"
\ . " echo '" . a:opt_name . " on'\n"
\ . "endif"
endfunction
nnoremap \ :call ToggleOption("wrap")<CR>
nnoremap <C-J> :cn<CR>
nnoremap <C-K> :cN<CR>
nnoremap <F2> :e #<CR>
nnoremap <Esc>2 :e #<CR>
cnoremap <Esc>h <Left>
cnoremap <Esc>j <Down>
cnoremap <Esc>k <Up>
cnoremap <Esc>l <Right>
cnoremap <Esc>H <Home>
cnoremap <Esc>L <End>
cnoremap <Esc>w <S-Right>
cnoremap <Esc>b <S-Left>
cnoremap <Esc>x <Del>
cnoremap <C-U> <C-E><C-U>
let mapleader=','
inoremap <Leader>df <C-R>=strftime('%Y-%m-%dT%H:%M:%S+09:00')<CR>
inoremap <Leader>dd <C-R>=strftime('%Y-%m-%d')<CR>
inoremap <Leader>dt <C-R>=strftime('%H:%M:%S')<CR>
set secure