Feed

hchbaw's watching list

Profile

.vim/はカオスですよ。

.vimrc

"
" based on the great .vimrc by Tom Glibert.
"

"
" When i ready to sing, i step up the microphones and it comes out Something
" like this.
"
if &term=="screen" || &term=="Eterm"
set term=xterm
endif

set langmenu=none
autocmd!
filetype on
syntax on

"set verbose=9

"set encoding=japan
set encoding=utf-8
set ambiwidth=double
"set ambiwidth=single
" try if new file then euc.
"autocmd BufNewFile * set fencs=euc-jp
" ok. mappings
nn ,eee :e ++enc=euc-jp<CR>
nn ,ees :e ++enc=cp932<CR>
nn ,eei :e ++enc=iso-2022-jp<CR>
nn ,eeu :e ++enc=utf-8<CR>

"
"
set vb t_vb=
set t_mr=

"set t_Co=16
"set t_AF=[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
"set t_AB=[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m

"set t_Co=88
"set t_AB=[48;5;%p1%dm
"set t_AF=[38;5;%p1%dm
"set t_Sb=%?%p1%{7}%>%t[48;5;%p1%dm%e[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;
"set t_Sf=%?%p1%{7}%>%t[38;5;%p1%dm%e[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;

let mapleader = ","
"==============
" SETTINGS
"==============

set autoindent
set norestorescreen
set t_ti= t_te=
set noautowrite
"set backspace=indent,eol,start
set backspace=2
set background=dark
set nobackup
"set backupdir=~/.vim/backups
set clipboard=autoselect
set nocompatible
set complete=.,b,u,w,t,i,d " buffers used for lookup in autocompletion
set cinoptions=>2,e0,n0,}0,^0,:2,=2,p2,t0,(2,)30,*40,+2,f0,{0,c2,u2
set cinkeys=0{,0},!^F,o,O,e,*<Return>,0#
set comments=s1:/*,mb:*,el:*/,://,b:#,:%,:XCOMM,nb:>,fb:-
set dictionary=/usr/share/dict/words
set noerrorbells
set equalprg="indent"
set esckeys
set expandtab
"set noexpandtab
set fileformat=unix " Always on a linux or unix box :-)
set fileformats=unix,mac,dos " Always on a linux or unix box :-)
set formatoptions=cqrtlm
set helpheight=0
set hidden
set highlight=8r,db,es,hs,mb,Mr,nu,rs,sr,tb,vr,ws
set history=100
set nohlsearch
set ignorecase
set incsearch
" iskeyword: Add the dash ('-'), the dot ('.'), and the '@'
" as "letters" to "words".
" iskeyword=@,48-57,_,192-255 (default)
set iskeyword=@,48-57,_,192-255,-,.,@-@
set laststatus=2
set listchars=eol:$,tab:>-
" lazyredraw: do not update screen while executing macros
set lazyredraw
" magic: use some magic in search patterns
set magic
" modeline: ...
" Allow the last few lines to be a modeline - useful when
" the last line in sig gives the preferred textwidth for replies.
set modeline
set modelines=4
set more
set mouse=a
set nonumber
set pastetoggle=<F9>
" path: The list of directories to search when you specify a file with an
" edit command.
"set path=.,~/,~/tomweb
set path=.,~/
set report=0
set restorescreen
set ruler
set scrolloff=0
set shell=zsh-beta
" shiftwidth: Number of spaces to use for each insertion of (auto)indent.
set shiftwidth=2
" String to put at the start of lines that have been wrapped.
" set showbreak="+++ "
set showbreak="+ "
" showcmd: Show current uncompleted command
set showcmd
" showmatch: Show the matching bracket for the last ')'?
set showmatch
set showmode
set smartcase
set smartindent
set smarttab
" startofline: do not jump to first character with page commands,
" ie keep the cursor in the current column.
set nostartofline
" suffixes: Ignore filename with any of these suffixes
" when using the ":edit" command.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.beam
set tabstop=2
"set tabstop=8
" Set the colors for vim on "xterm"
set tildeop
set textwidth=76
set title
set ttyfast
set undolevels=1000 " undoing 1000 changes should be enough :-)
set updatecount=100 " write swap file to disk after each 200 characters
set updatetime=6000 " write swap file to disk after 5 inactive seconds
" viminfo: What info to store from an editing session
" in the viminfo file; can be used at next session.
set viminfo=%,'50,\"100,:500,n~/.viminfo
set whichwrap=<,>,b,s,[,]
" wildchar the char used for "expansion" on the command line
"set wildchar=<TAB>
"set foldlevel=100
"set foldmethod=marker
"set wildmode=list:longest
set wildmode=longest,list

"if &term=="xterm"
" set t_Co=8 " "terminal has eight colors"
" set t_Sb=[4%dm " escape sequence for background
" set t_Sf=[3%dm " escape sequence for foreground
"endif

"if has("autocmd")
" filetype plugin indent on
"endif

" ===================================================================
" Abbreviations
" ===================================================================
" source ~/.abbr.vimrc
"
" ===================================================================
" MAPpings
" ===================================================================
" Caveat: Mapping must be "prefix free", ie no mapping must be the
" prefix of any other mapping. Example: "map ,abc foo" and
" "map ,abcd bar" will give you the error message "Ambigous mapping".
"
" The following maps get rid of some basic problems:
"
" Disable the suspend for ^Z.
" map <C-Z> :shell
"
" When I let Vim write the current buffer I frequently mistype the
" command ":w" as ":W" - so I have to remap it to correct this typo:
nmap :W :w
nmap :Q :q

map Q gq
" Don't use Ex mode, use Q for formatting
"
" ===================================================================
" VIM - Editing and updating the vimrc:
" As I often make changes to this file I use these commands
" to start editing it and also update it:
let vimrc='~/.vimrc'
let myabbr='~/.abbr.vimrc'
nn ,vu :source <C-R>=vimrc<CR><CR>
nn ,ve :edit <C-R>=vimrc<CR><CR>
nn ,vy :edit <C-R>=myabbr<CR><CR>
" ===================================================================
"
" General Editing
"
" ;rcm = remove "control-m"s - for those mails sent from DOS:
cmap ;rcm %s/<C-M>//g
"
" Make whitespace visible:
" Sws = show whitespace
nmap ,Sws :%s/ /_/g<C-M>
vmap ,Sws :%s/ /_/g<C-M>
"
" Sometimes you just want to *see* that trailing whitespace:
" Stws = show trailing whitespace
nmap ,Stws :%s/ *$/_/g<C-M>
vmap ,Stws :%s/ *$/_/g<C-M>
"
" ===================================================================
" General Editing
" ===================================================================
"
" ,cel = "clear empty lines"
" - delete the *contents* of all lines which contain only whitespace.
" note: this does not uelete lines!
map ,cel :%s/^\s\+$//
" ,del = "delete 'empty' lines"
" - delete all lines which contain only whitespace
" note: this does *not* delete empty lines!
map ,del :g/^\s\+$/d
"
" ,cqel = "clear quoted empty lines"
" Clears (makes empty) all lines which start with '>'
" and any amount of following spaces.
nmap ,cqel :%s/^[>]\+$//
vmap ,cqel :s/^[><C-I> ]\+$//
"
" ,ksr = "kill space runs"
" substitutes runs of two or more space to a single space:
nmap ,ksr :%s/ \+/ /g
vmap ,ksr :s/ \+/ /g
"
" ,Sel = "squeeze empty lines"
" Convert blocks of empty lines (not even whitespace included)
" into *one* empty line (within current visual):
map ,Sel :g/^$/,/./-j
"
" ,Sbl = "squeeze blank lines"
" Convert all blocks of blank lines (containing whitespace only)
" into *one* empty line (within current visual):
map ,Sbl :g/^\s*$/,/\S/-j
"
" ===================================================================
" Editing of email replies and Usenet followups - using autocommands
" ===================================================================
" Part 3 - Change Quoting Level
map ,dp vip:s/^> //<CR>
vmap ,dp :s/^> //<CR>
"
" ,qp = "quote current inner paragraph"
" select inner paragraph
" then do the quoting as a substitution:
map ,qp vip:s/^/> /<CR>
"
" ,qp = "quote current paragraph"
" just do the quoting as a substitution:
vmap ,qp :s/^/> /<CR>
" Changing quote style to *the* true quote prefix string "> ":
"
" ,kpq "kill power quote"
vmap ,kpq :s/^> *[a-zA-Z]*>/> >/<C-M>
"
" Fix various other quote characters:
" ,fq "fix quoting"
vmap ,fq :s/^> \([-":}\|][ <C-I>]\)/> > /
"
" Part 5 - Reformatting Text
"
" Formatting the current paragraph according to
" the current 'textwidth' with ^J (control-j):
imap <C-J> <c-o>gqap
map <C-J> gqap
"
" ,j = join line in commented text
" (can be used anywhere on the line)
" nmap ,j Jxx
nmap ,j Vjgq
"
" ===================================================================
" Editing your reply
" ===================================================================
"
" Part 6 - Inserting Special or Standard Text
"
" Put parentheses around "visual text"
" Used when commenting out an old subject.
"
" ,) and ,( :
vmap ,( v`<i(<ESC>`>a)<ESC>
vmap ,) v`<i(<ESC>`>a)<ESC>
vmap ," c""<left><C-R>"<ESC>
"
" remove signatures
"
" ,kqs = kill quoted sig (to remove those damn sigs for replies)
" goto end-of-buffer, search-backwards for a quoted sigdashes
" line, ie "^> -- $", and delete unto end-of-paragraph:
" map ,kqs G?^> -- $<CR>d}
" map ,kqs G?^> *-- $<CR>dG
" ,kqs = kill quoted sig unto start of own signature:
map ,kqs G?^> *-- $<CR>d/^-- $/<C-M>
"
" ,aq = "add quote"
nmap ,aq :r!fortune<CR><ESC>b
" Indent a C file.
nmap ,ci :w<CR>:!indent %<CR>:e!<CR>
"
" ===================================================================
" HTML
" ===================================================================
" This has become quite big - so I moved it out to another file:
" let FILE=expand("~/.vim/html.vim")
" The "expand" is necessary to evauluate "~".
" if filereadable(FILE)
" exe "source " . FILE
" endif
let html_my_rendering=1
"
" ===================================================================
" Useful stuff. :-)
" ===================================================================
"
" ,E = execute line
map ,E 0/\$<CR>w"yy$:<C-R>y<C-A>r!<C-E>
" This command excutes a shell command from the current line and
" reads in its output into the buffer. It assumes that the command
" starts with the fist word after the first '$' (the shell prompt
" of /bin/sh). Try ",E" on that line, ie place the cursor on it
" and then press ",E":
" $ ls -la
"
" ,dr = decode/encode rot13 text
vmap ,dr :!tr A-Za-z N-ZA-Mn-za-m
" Use this with an external "rot13" script:
" " ,13 - rot13 the visual text
" vmap ,13 :!rot13<CR>
"
map ,vc I/* <esc>$a */<esc><cr>
map ,Vc /\/\*/<cr>Nxxx/\*\//<cr>xxx``$
" ===================================================================
" Mapping of special keys - arrow keys and function keys.
" ===================================================================
map <F1> oD_ENTER;<ESC>
map <F2> oD_RETURN_;<ESC>
map <F3> oD_RETURN();<ESC>hi
map <F4> iD_RETURN(<ESC>$i)<ESC>
" Buffer commands (split,move,delete) -
" this makes a little more easy to deal with buffers.
map <F5> :split<C-M>
map <F6> :bp<C-M>
map <F7> :bn<C-M>
map <F8> :bd<C-M>

" <Tab> is bound to `complete'
inoremap <tab> <c-p>
"
" cycle fast thru buffers ...
"nnoremap <C-n> :bn<CR>
"nnoremap <C-p> :bp<CR>
"
" cycle fast thru errors ...
map <m-n> :cn<cr>
map <m-p> :cp<cr>

fun! InsertChangeLog()
normal(1G)
call append(0, strftime("%a %b %d %T %Z %Y") . " Foo Bar <blah@example.com>")
call append(1, "")
call append(2, " * ")
call append(3, "")
execute ':3'
normal($)
endfun
map ,cl :call InsertChangeLog()<cr>A
" ===================================================================
" AutoCommands
" ===================================================================
"so $VIMRUNTIME/syntax/syntax.vim
"syntax on

augroup cprog
au!
autocmd FileType c,cpp filetype plugin on
autocmd FileType c,cpp set noautoindent cindent formatoptions=croql ts=8 sw=3 sts=8 noexpandtab cino=>5n-3f0^-2{2(0
augroup END
"augroup cprog
" au!
" "autocmd BufRead * set formatoptions=trcql autoindent nocindent comments&
" autocmd FileType c,cpp set noautoindent cindent formatoptions=croql shiftwidth=2 softtabstop=2 textwidth=78 wrapmargin=3
"" autocmd FileType c,cpp source ~/.vim/my_c_syntax.vim
"augroup END

"augroup html
" au!
" autocmd FileType html set nocindent autoindent sw=2 ts=8 expandtab equalprg=tidy\ -quiet\ --show-warnings\ no makeprg=tidy\ -quiet\ -e\ % errorformat=
" \%Eline\ %l\ column\ %c\ -\ Error:%m,
" \%Wline\ %l\ column\ %c\ -\ Warning:%m
"" so ~/.vim/html.vim
"augroup END
"
augroup gitcommit
au!
autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit notitle tw=72
autocmd BufEnter COMMIT_EDITMSG :normal 1G0
augroup END

augroup sql
au!
autocmd BufRead psql.edit* setl ft=sql notitle
augroup END

augroup changelog
au!
autocmd BufEnter *ChangeLog* :normal 1G0
augroup END

augroup php
au!
autocmd FileType php set nocindent autoindent sw=2 ts=2 expandtab
" autocmd FileType php set expandtab noautoindent ts=2 softtabstop=2 sw=2 cindent cinoptions=>2,e0,n0,}0,^0,:2,=3,p3,t0,(3,)30,*40,+3,f0,{0,c3,u3
augroup END

augroup make
au!
autocmd FileType make setl noexpandtab
augroup END

augroup ruby
au!
autocmd FileType ruby filetype plugin indent on
autocmd FileType ruby compiler ruby
augroup END
augroup scheme
au!
"autocmd FileType scheme setl lw+=let1,define-method
autocmd FileType scheme :let is_gauche=1
autocmd FileType scheme filetype plugin indent on
autocmd FileType scheme so ~/.vim/VIlisp.vim
augroup END
augroup lisp
au!
autocmd FileType lisp setl lw+=with-gensyms,defgeneric,block,catch
autocmd FileType lisp filetype plugin indent on
autocmd FileType lisp so ~/.vim/VIlisp.vim
augroup END
augroup erlang
au!
autocmd FileType erlang filetype plugin indent on
augroup END
augroup mail
au!
au BufNewFile,BufRead .letter,mutt*,nn.*,snd.* setl tw=72 notitle
augroup END

augroup velocity
au!
au BufNewFile,BufRead *.vm setl ft=velocity
augroup END
augroup svn
au!
autocmd BufEnter svn-commit.* :normal 1G0
autocmd BufEnter svn-commit.* setl ft=svn notitle
augroup END

"augroup java
" au!
"" autocmd FileType java set enc=utf-8 tenc=euc-jp
" autocmd FileType java so ~/.vim/macros/jcommenter-config.vim
" autocmd FileType java so ~/.vim/macros/jcommenter.vim
" autocmd FileType java so ~/.vim/JavaImp.vim
"augroup END
augroup java
au!
" autocmd BufNewFile,BufReadPre *.java setl enc=cp932 tenc=utf-8
" autocmd FileType java setl ff=dos ts=4 sw=4

" autocmd BufNewFile,BufReadPre *.java setl enc=utf-8 tenc=utf-8
" autocmd FileType java setl ff=unix ts=4 sw=4

autocmd BufNewFile,BufReadPre *.java setl enc=utf-8 tenc=utf-8
autocmd FileType java setl ff=unix ts=2 sw=2

autocmd FileType java so ~/.vim/macros/jcommenter-config.vim
autocmd FileType java so ~/.vim/macros/jcommenter.vim
autocmd FileType java so ~/.vim/JavaImp.vim
" autocmd FileType java setl makeprg=ant\ -emacs
autocmd FileType java setl makeprg=ant\ -emacs\ -Djavac.compilerarg=\"-Xemacs\ -warn:-serial\ -warn:-raw\"
autocmd FileType java setl efm=f:%l:%v:%*\\d:%*\\d:%*\\s%m,%f:%l:%m,%A%*\\d.\ %t%.%#\ in\ %f,%C\ (at\ line\ %l),%-C\ %.%#,%Z%m
augroup END
augroup groovy
au!
autocmd BufNewFile,BufReadPre *groovy setl enc=utf-8 tenc=utf-8
autocmd FileType groovy setl ff=unix ts=2 sw=2
autocmd FileType groovy so ~/.vim/macros/jcommenter-config.vim
autocmd FileType groovy so ~/.vim/macros/jcommenter.vim
autocmd FileType groovy so ~/.vim/JavaImp.vim
" autocmd FileType java compiler ant\ -emacs
autocmd FileType groovy setl makeprg=ant\ -emacs
autocmd FileType groovy setl efm=f:%l:%v:%*\\d:%*\\d:%*\\s%m,%f:%l:%m,%A%*\\d.\ %t%.%#\ in\ %f,%C\ (at\ line\ %l),%-C\ %.%#,%Z%m
augroup END
augroup jsp
au!
" autocmd BufNewFile,BufReadPre *.jsp setl enc=cp932 tenc=utf-8
autocmd BufNewFile,BufReadPre *.jsp setl enc=utf-8 tenc=utf-8
autocmd FileType jsp setl ts=2 sw=2 tw=1024 expandtab
" autocmd BufNewFile,BufReadPre *.jsp setl enc=utf-8 tenc=utf-8
" autocmd FileType jsp setl ff=unix ts=2 sw=2 tw=1024
augroup END
augroup ftl
au!
autocmd BufNewFile,BufReadPre *.ftl setf ftl
augroup END
augroup debchangelog
au!
autocmd FileType debchangelog filetype plugin indent on
augroup END
"augroup java
" au!
" autocmd FileType java set enc=cp932 tenc=euc-jp
" autocmd FileType java set ff=dos ts=4 sw=4
" autocmd FileType java so ~/.vim/macros/jcommenter-config.vim
" autocmd FileType java so ~/.vim/macros/jcommenter.vim
" autocmd FileType java so ~/.vim/JavaImp.vim
"augroup END
"augroup jproperties
" au!
" autocmd FileType jproperties set enc=utf-8 tenc=euc-jp
"augroup END
"augroup javascript
" au!
" autocmd FileType javascript set enc=utf-8 tenc=euc-jp
"augroup END
"
"augroup html
" au!
" autocmd FileType html set enc=cp932 tenc=euc-jp
" autocmd FileType html set ff=dos ts=4 sw=4
"augroup END
"augroup xml
" au!
" autocmd FileType xml set enc=cp932 tenc=euc-jp
" autocmd FileType xml set ff=dos ts=4 sw=4
"augroup END

"augroup jsp
" au!
" autocmd FileType jsp set enc=cp932 tenc=euc-jp
" autocmd FileType jsp set ff=dos ts=4 sw=4
"augroup END
"augroup jproperties
" au!
" autocmd FileType jproperties set enc=cp932 tenc=euc-jp
"augroup END
"augroup javascript
" au!
" autocmd FileType javascript set enc=cp932 tenc=euc-jp
"augroup END
"augroup changelog
" au!
" autocmd BufNewFile,BufRead ++log* set ff=dos ft=changelog enc=cp932 tenc=euc-jp
"augroup END

"augroup cvs
" au!
" autocmd FileType cvs set enc=utf-8 tenc=euc-jp
"augroup END
" ===================================================================
" TEMPORARY STUFF - TESTING THINGS
" ===================================================================
"
" Some simple example of the "expand modifiers":
" insert the current filename *with* path:
" iab _PATHFILE <C-R>=expand("%:p")<cr>
" insert the current filename *without* path:
" iab _FILE <C-R>=expand("%:t:r")<cr>
" insert the path of current file:
" iab _PATH <C-R>=expand("%:h")<cr>

" this will jump to the last edited buffer, if VIM is invoked W/O COMMANDS
"autocmd VimEnter * nested if argc() == 0 && bufname ("%") == "" && bufname ("2" + 0) != "" | exe ("normal '0") | endif
autocmd BufRead *,.* :normal '"

" this means vim will always jump to the last edited line in a file if poss

"source ~/.selectBuffer.vim
"source ~/.vim/bracket-macros.vim
source ~/.vim/comment.vim
"source ~/.vim/bufexplorer.vim
"source ~/.vim/explorer.vim
"source ~/.vim/word_complete.vim
"source ~/.vim/my_syntax.vim
"source ~/.vim/color.vim
"

colo mine
let g:xml_syntax_folding = 1

let g:JavaImpPaths = $HOME . "/.javaimp/jmplst" .
\ "," . $HOME . "/c/dists/spring/src" .
\ "," . $HOME . "/c/dists/spring/mock"
let g:JavaImpDataDir = $HOME . "/.javaimp"
"set titlestring=%t\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (%{expand(\"%:p:~:h\")})%(\ %M%R%H%)\ -\ VIM
"vim:tw78 et sw=4 comments=\:\"