PCが変わるたびにvimの設定をするのが面倒なので、
完全に俺得なvimの設定をまとめる
Env
- OSX 10.11.3
- VIM - Vi IMproved 7.3
Ref
http://qiita.com/kotashiratsuka/items/dcd1f4231385dc9c78e7
Settings
Create vimrc
"-------------------------
"settings for find
set wrapscan
set hlsearch
"-------------------------
"settings for highlight
set showmatch
"-------------------------
"settings for footer(command line, status line, ...)
"command line settings
set wildchar=<C-Z>
set cmdheight=1
"status line settings
augroup WordCount
autocmd!
autocmd BufWinEnter,InsertLeave,CursorHold * call WordCount('char')
augroup END
let s:WordCountStr = ''
let s:WordCountDict = {'word': 2, 'char': 3, 'byte': 4}
function! WordCount(...)
if a:0 == 0
return s:WordCountStr
endif
let cidx = 3
silent! let cidx = s:WordCountDict[a:1]
let s:WordCountStr = ''
let s:saved_status = v:statusmsg
exec "silent normal! g\<c-g>"
if v:statusmsg !~ '^--'
let str = ''
silent! let str = split(v:statusmsg, ';')[cidx]
let cur = str2nr(matchstr(str, '\d\+'))
let end = str2nr(matchstr(str, '\d\+\s*$'))
if a:1 == 'char'
" ここで(改行コード数*改行コードサイズ)を'g<C-g>'の文字数から引く
let cr = &ff == 'dos' ? 2 : 1
let cur -= cr * (line('.') - 1)
let end -= cr * line('$')
endif
let s:WordCountStr = printf('%d/%d', cur, end)
endif
let v:statusmsg = s:saved_status
return s:WordCountStr
endfunction
set showcmd
set laststatus=2
set statusline+=%{matchstr(hostname(),'\\w\\+')}@
set statusline+=%<%F
set statusline+=%r
set statusline+=%h
set statusline+=%w
set statusline+=[%{&fileformat}]
set statusline+=[%{has('multi_byte')&&\&fileencoding!=''?&fileencoding:&encoding}]
set statusline+=%y
set statusline+=%=
set statusline+=%{exists('*SkkGetModeStr')?SkkGetModeStr():''}
set statusline+=[%{col('.')-1}=ASCII=%B,HEX=%c]
set statusline+=[C=%c/%{col('$')-1}]
set statusline+=[L=%l/%L]
set statusline+=[WC=%{exists('*WordCount')?WordCount():[]}]
set statusline+=[%p%%]
"-------------------------
"settings for virtual box
set virtualedit=block
"-------------------------
"settings for indent
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
"-------------------------
"settings for keybindings
"keybindings like emacs
noremap! <C-A> <Home>
noremap! <C-B> <Left>
noremap! <C-D> <Delete>
noremap! <C-H> <Left><Delete>
noremap! <C-E> <End>
noremap! <C-F> <Right>
noremap! <C-N> <Down>
noremap! <C-P> <Up>
noremap <C-A> <Home>
noremap <C-B> <Left>
noremap <C-D> <Delete>
noremap <C-H> <Left><Delete>
noremap <C-E> <End>
noremap <C-F> <Right>
noremap <C-N> <Down>
noremap <C-P> <Up>
"quick ESC on insert mode
inoremap <C-C> <ESC>
"off to highlight on pressing ESC
nmap <ESC><ESC> :noh<CR>
"------------------------
"settings for GUI
"can use wildmenu
set whichwrap=b,s,[,],<,>
set wildmenu
"can use clipboard
set clipboard+=unnamed
"can use mouse
if has ("mouse")
set mouse=a
set guioptions+=a
set ttymouse=xterm2
endif
"----------------------
"settings for Unicode
set ambiwidth=double
"-----------------------
"settings for history
set history=50
"-----------------------
"other settings
"visible TAB,EOL,...
set list
set listchars=tab:»-,trail:-,eol:↲,extends:»,precedes:«,nbsp:%
"show ruler
set ruler
"show line number
set number
"show cursor line
set cursorline
"show title
set title
"can edit multiple files
set hidden
"can remove line head on pressing backspace key
set backspace=indent,eol,start