Last active
February 22, 2016 06:05
-
-
Save rkaneko/a5cf0bccfe8ffb01fec7 to your computer and use it in GitHub Desktop.
minimal .vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" .vimrc.min | |
set nobackup " not make backup file | |
set autoread " read automatically file which is written on the other hand | |
set noswapfile " not make swap file | |
set textwidth=0 " not turn up long sentence | |
set hidden " can open a file editting on the other hand | |
set backspace=indent,eol,start " remove all with backspace key | |
set whichwrap=b,s,[,],<,>,~ " moving as screen editor | |
set showcmd " show command on the status line | |
set showmode " show current mode | |
set vb t_vb= " off beep sound | |
" If input contains Large letters, ignore case | |
set ignorecase | |
set smartcase | |
" set list " show white space and etc | |
set shortmess& shortmess+=I " disable showing message on startup time | |
set imdisable " use IM: When u escape input mode, automatically set IME off.(Enable only KaoriYa Vim) | |
set iminsert=0 imsearch=0 " on startup time set IME off | |
set noimcmdline " on command line set IME off | |
" insertモードを抜けるとIMEオフ(この下の二つのコメントを外すとinsertモードでカーソルキー移動ができなくなる) | |
" inoremap <silent> <ESC> <ESC> | |
" inoremap <silent> <C-[> <ESC> | |
set hlsearch " high light words u are searching | |
" clear high light with ESC + ESC | |
nnoremap <silent><Esc><Esc> :<C-u>nohlsearch<CR> | |
set incsearch | |
" 検索後画面の中心に | |
nnoremap n nzvzz | |
nnoremap N Nzvzz | |
nnoremap * *zvzz | |
nnoremap # *zvzz | |
nnoremap <C-Space> i<Space><Esc><Right> " insert space with C-Space | |
" doesn't put comment on starting new line | |
set formatoptions-=r | |
set formatoptions-=o | |
set fileformats=unix,dos,mac | |
set ttyfast | |
set ambiwidth=double | |
set whichwrap +=h | |
set whichwrap +=l | |
set history=100 | |
if has('persistent_undo') | |
if ! isdirectory($HOME.'/.vim/undo') | |
call mkdir($HOME.'/.vim/undo', 'p') | |
endif | |
set undodir=~/.vim/undo | |
set undofile | |
endif | |
" 行数が少ない時だけ行数表示 | |
autocmd BufEnter * if line('$') > 10000 | setlocal nonumber | else | setlocal number | endif | |
" open file with specifying encoding | |
command! -bang -complete=file -nargs=? Utf8 edit<bang> ++enc=utf-8 <args> | |
command! -bang -complete=file -nargs=? Sjis edit<bang> ++enc=cp932 <args> | |
command! -bang -complete=file -nargs=? Euc edit<bang> ++enc=eucjp <args> | |
set clipboard+=unnamed,autoselect " use OS clipboard | |
" use mouse on Terminal | |
set mouse=a | |
set guioptions+=a | |
set ttymouse=xterm2 | |
" On insert mode, you can put clipped letters with Ctrl+p | |
imap <C-p> <ESC>"*pa | |
" delete buffer | |
function! s:delete_current_buf() | |
let bufnr = bufnr('%') | |
bnext | |
if bufnr == bufnr('%') | enew | endif | |
silent! bdelete # | |
endfunction | |
nnoremap <C-w>d :<C-u>call <SID>delete_current_buf()<CR> | |
nnoremap <C-w>D :<C-u>bdelete<CR> | |
" see : http://atasatamatara.hatenablog.jp/entry/2013/03/07/215806 | |
" copy text with Ctrl+c | |
vmap <C-c> :w !xsel -ib<CR><CR> | |
" Ev/Rv : edit/reflect .vimrc | |
command! Ev edit $MYVIMRC | |
command! Rv source $MYVIMRC | |
set helpfile=$VIMRUNTIME/doc/help.txt | |
"" tab and indent | |
" ref : http://goo.gl/fHiE7 | |
set expandtab " If you types tab key, vim replaces tab with spaces . | |
set tabstop=4 " tab is 4 spaces on vim view | |
set shiftwidth=4 " auto indent config , indent width is 4 spaces | |
set softtabstop=4 " If you types tab key on continuous spaces, you can move 4 spaces . | |
set autoindent " When you start new line, auto indent is available . | |
set smartindent " Whew you start new line, vim makes indent judging from line tail . | |
" encoding | |
set enc=utf-8 | |
set fenc=utf-8 | |
set fencs=utf-8,iso-2022-jp,cp932,sjis,euc-jp | |
" paste option | |
" see : http://qiita.com/quwa/items/019250dbca167985fe32 | |
imap <F9> <nop> | |
set pastetoggle=<F9> | |
" turn off auto indent when pasting from clipboard | |
if &term =~ "xterm" | |
let &t_ti .= "\e[?2004h" | |
let &t_te .= "\e[?2004l" | |
let &pastetoggle = "\e[201~" | |
function! XTermPasteBegin(ret) | |
set paste | |
return a:ret | |
endfunction | |
noremap <special> <expr> <Esc>[200~ XTermPasteBegin("0i") | |
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("") | |
cnoremap <special> <Esc>[200~ <nop> | |
cnoremap <special> <Esc>[201~ <nop> | |
endif | |
inoremap <C-d> <Del> | |
" when insert mode jj is esc | |
inoremap jj <Esc> | |
" split vertical | |
nnoremap sv :vs<CR> | |
" split horizontal | |
nnoremap ss :sp<CR> | |
" see : http://c4se.hatenablog.com/entry/2013/03/10/032917 | |
" 保存時にfiletypeがmarkdown以外の時は行末の空白を除去する | |
function! s:delete_end_of_sentence() | |
let position = getpos('.') | |
if &filetype !~ 'markdown' | |
" autocmd BufWritePre * :%s/\s\+$//ge | |
:%s/\s\+$//ge | |
endif | |
call setpos('.', position) | |
endfunction | |
command! DeleteEOT call s:delete_end_of_sentence() | |
" 保存時にfiletypeがmake以外の時はtabをスペースに変換する | |
function! s:replace_tab_to_space() | |
let position = getpos('.') | |
if &filetype !~ 'make' | |
" :%s/\t/ /ge | |
set expandtab | |
retab | |
endif | |
call setpos('.', position) | |
endfunction | |
augroup vimrc_rkaneko_bufwritepre | |
autocmd! | |
" autocmd BufWritePre * call s:delete_end_of_sentence() | |
autocmd BufWritePre * call s:replace_tab_to_space() | |
augroup END | |
" moving buffer | |
nnoremap <silent>bp :bprevious<CR> | |
nnoremap <silent>bp :bnext<CR> | |
nnoremap <silent>bb :b#<CR> | |
set showmatch " 括弧の対応をハイライト | |
set number " show line number | |
"set list " 不可視文字表示 | |
" see : http://goo.gl/dToJC | |
" show line tail space | |
highlight WhitespaceEOL cterm=underline ctermbg=red guibg=#FF0000 | |
au BufWinEnter * let w:m1 = matchadd("WhitespaceEOL", ' +$') | |
au WinEnter * let w:m1 = matchadd("WhitespaceEOL", ' +$') | |
" show line head tab | |
highlight TabString ctermbg=red guibg=red | |
au BufWinEnter * let w:m2 = matchadd("TabString", '^\t+') | |
au WinEnter * let w:m2 = matchadd("TabString", '^\t+') | |
" show fullwidth space | |
highlight ZenkakuSpace cterm=underline guibg=#666666 | |
au BufWinEnter * let w:m3 = matchadd("ZenkakuSpace", ' ') | |
au WinEnter * let w:m3 = matchadd("ZenkakuSpace", ' ') | |
set cursorline " highlight cursor line | |
" change completion menu background | |
highlight Pmenu ctermbg=black | |
highlight PmenuSel ctermbg=grey | |
highlight PmenuSbar ctermbg=lightcyan | |
" color scheme | |
syntax enable | |
if !has('gui_running') | |
set t_Co=256 | |
endif | |
set background=dark | |
try | |
colorscheme solarized | |
catch | |
endtry | |
" 背景を半透明に | |
highlight Normal ctermbg=none | |
" ターミナルタイプによるカラー設定 | |
if &term =~ "xterm-256color" || "screen-256color" | |
" 256色 | |
set t_Co=256 | |
set t_Sf=[3%dm | |
set t_Sb=[4%dm | |
elseif &term =~ "xterm-debian" || &term =~ "xterm-xfree86" | |
set t_Co=16 | |
set t_Sf=[3%dm | |
set t_Sb=[4%dm | |
elseif &term =~ "xterm-color" | |
set t_Co=8 | |
set t_Sf=[3%dm | |
set t_SB=[4%dm | |
endif | |
" statusline setting | |
" insert mode で色変更 | |
let g:hi_insert = 'highlight StatusLine guifg=darkblue guibg=darkyellow gui=none ctermfg=blue ctermbg=yellow cterm=none' | |
if has('syntax') | |
augroup InsertHook | |
autocmd! | |
autocmd InsertEnter * call s:StatusLine('Enter') | |
autocmd InsertLeave * call s:StatusLine('Leave') | |
augroup END | |
endif | |
if has('unix') && !has('gui_running') | |
" ESCでキー入力待ちになる対策 | |
inoremap <silent> <ESC> <ESC> | |
endif | |
let s:slhlcmd = '' | |
function! s:StatusLine(mode) | |
if a:mode == 'Enter' | |
silent! let s:slhlcmd = 'highlight ' . s:GetHighlight('StatusLine') | |
silent exec g:hi_insert | |
else | |
highlight clear StatusLine | |
silent exec s:slhlcmd | |
redraw | |
endif | |
endfunction | |
function! s:GetHighlight(hi) | |
redir => hl | |
exec 'highlight '.a:hi | |
redir END | |
let hl = substitute(hl, '[\r\n]', '', 'g') | |
let hl = substitute(hl, 'xxx', '', '') | |
return hl | |
endfunction | |
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [FT=%Y]\ [ENC=%{&fileencoding}]\ [POS=%04l,%04v][%p%%]\ [LEN=%L] | |
set laststatus=2 | |
if has('multi_byte_ime') | |
highlight Cursor guifg=NONE guibg=Green | |
highlight CursorIM guifg=NONE guibg=Purple | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment