Vimのマイ設定
プラグインっぽいのも中に書いちゃってる。
behave mswin
set nocompatible
set shell=bash.exe\ -i
set noshellslash
set fileformat=unix
set fileformats=unix,dos,mac
set number
set shiftwidth=2
set tabstop=2
set noexpandtab
set hlsearch
set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %F%=[%{GetB()}]\ %l,%c%V%8P
set showmatch
set cindent
set autoindent
set backspace=indent,eol,start
set listchars=tab:>-
set iminsert=0
set imsearch=0
set laststatus=2
set backup
set backupdir=~/vimfiles/backup/
set selectmode=
set hidden
set directory=~/vimfiles/swap/
set complete=.,b,w,u,U,k
filetype plugin indent on
syntax on
cd ~/
set showcmd
set ignorecase
set smartcase
set incsearch
set cmdheight=1
set nrformats=hex
set background=dark
set scrolloff=0
set noautoread
set noexrc
set nrformats-=octal
if v:version >= 700
set showtabline=2
set autochdir
endif
let MRU_Max_Entries = 30
let g:treeExplVertical = 1
let g:treeExplWinSize = 30
let g:howm_dir = "~/vimfiles/data/howm/"
"/usr/bin/grep"
"/usr/bin/find"
let Tlist_Ctags_Cmd = 'ctags'
let ruby_minlines = 100
cmap <C-a> <Home>
cmap <C-e> <End>
cmap <C-f> <Right>
cmap <C-b> <Left>
imap <C-x><C-s> <ESC>:w<CR>a
inoremap <C-b> <Esc>kA
map \x :bdelete<CR>
map \, :bprev<CR>
map \. :noautocmd bnext<CR>
map \bx :bdelete<CR>
map \< :tabprev<CR>
map \> :tabnext<CR>
map \te :tabedit
map \tx :tabclose<CR>
map \tn :tabnew<CR>
map \ta :tab ball<CR>
map \to :tabonly<CR>
map \ts :tabs<CR>
map <Space> :noautocmd bnext<CR>
map <C-Space> :bprev<CR>
map <Up> :tabprev<CR>
map <Down> :tabnext<CR>
map <Left> :bprev<CR>
map <Right> :noautocmd bnext<CR>
map \y :YRShow<CR>
vnoremap <C-S> y:%s/<C-R>"//g<Left><Left>
nmap n nzz
nmap N Nzz
nmap * *zz
nmap # #zz
nmap g* g*zz
nmap g# g#zz
map \<CR> o<ESC>
map \\hl :set hlsearch!<CR>
map \\li :set list!<CR>
map \\text :map p :put^V^V
Go^V^V^[<CR>:w<CR>
map \\spell :lcd<CR>:w!<CR>:!aspell --lang=en --ignore-case -c %<CR>:e! %<CR>
map \\vrc :e ~/_vimrc<CR>
map \\gvrc :e ~/_gvimrc<CR>
map \\memo :e ~/.vimemo<CR>
imap <C-a> <Home>
imap <C-e> <End>
imap <C-f> <Right>
imap <C-b> <Left>
map \\cl :set cursorline!<CR>
map \\read :set scrolloff=666<CR>:highlight Cursor guifg=NONE guibg=NONE<CR>
imap <C-Space> <C-x><C-o><C-p>
nmap <unique> <silent> <C-S> :LUBufs<CR>
let g:LookupFile_AlwaysAcceptFirst=1
let g:LookupFile_PreserveLastPattern=0
let g:LookupFile_AllowNewFiles=0
command! Rc :e ~/_vimrc
command! Grc :e ~/_gvimrc
command! -nargs=1 Reenco :e ++enc=<args>
command! Date normal o<ESC>!!date<CR>==
map \date :Date<CR>
command! Shell :call InitShell()
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif
autocmd BufNewFile,BufRead *.as set ft=javascript
autocmd BufNewFile,BufRead *.pxd set ft=xml
autocmd BufNewFile,BufRead */mover/temp/*.txt set fenc=cp932
function! Scratch ()
:new
:set buftype=nowrite
endfunction
command! Scratch :call Scratch()
if &encoding !=# 'utf-8'
set encoding=japan
endif
set fileencoding=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'
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\|jisx0213\)$'
set fileencodings+=cp932
set fileencodings-=euc-jp
set fileencodings-=euc-jisx0213
let &encoding = s:enc_euc
else
let &fileencodings = &fileencodings .','. s:enc_euc
endif
endif
unlet s:enc_euc
unlet s:enc_jis
endif
function! GetB()
let c = matchstr(getline('.'), '.', col('.') - 1)
let c = iconv(c, &enc, &fenc)
return String2Hex(c)
endfunction
func! Nr2Hex(nr)
let n = a:nr
let r = ""
while n
let r = '0123456789ABCDEF'[n % 16] . r
let n = n / 16
endwhile
return r
endfunc
func! String2Hex(str)
let out = ''
let ix = 0
while ix < strlen(a:str)
let out = out . Nr2Hex(char2nr(a:str[ix]))
let ix = ix + 1
endwhile
return out
endfunc
set statusline=%<[%n]%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'}%y\ %f%=[%{GetB()}]\ %l,%c%V%8P
function! LoadTemplate()
if &filetype == ''
return
endif
if getfsize(bufname("")) > 10
return
endif
let filename = $HOME . 'vimfiles/template/' . &filetype . '.txt'
if !filereadable(filename)
return
endif
execute 'read ' . filename
go 1
delete
normal G
set fileencoding=cp932
endfunction
autocmd BufNewFile,BufRead * :call LoadTemplate()
if v:version >= 700
function! TabLine()
let res = ''
let curtab = tabpagenr()
let i = 1
for i in range(1, tabpagenr('$'))
let res .= ((i == curtab) ? '%#TabLineSel#' : '%#TabLine#')
let res .= i . '-' . tabpagewinnr(i, '$') . ':'
let res .= substitute(bufname(tabpagebuflist(i)[0]), '.\+\/', '', 'g')
let res .= ' '
let i += 1
exe | endfor
let res .= '%#TabLineFill#'
return res
endfunction
set tabline=%!TabLine()
endif
set viewdir=~/vimfiles/view
au BufWritePost * mkview
autocmd BufReadPost * loadview
function! RemoveBrackets ()
ruby <<
$KCODE = 'sjis'
buf = VIM::Buffer.current
buf.count.times do
|lc|
lc += 1
ls = buf[lc]
ls.gsub! /[\[\(【(].+?[\]\))】]/, ''
ls.gsub! /^\s+/, ''
buf[lc] = ls
end
.
endfunction
":nnoremap <buffer> <space> :bwipeout<cr>"
let mapleader = ","
function! Size ()
let r = 0
for i in range(1, line('$'))
if match(getline(i), "^#")
let r += len(getline(i))
endif
endfor
echo r
endfunction
map \\size :call Size()<CR>