root/dotfiles/vim/mattn-vimrc

Revision 2144, 8.8 kB (checked in by mattn, 9 months ago)

dotfiles/vim/mattn-vimrc: added my vimrc

Line 
1" vi:set ts=8 sts=2 sw=2 tw=0:
2" vim:fdm=marker fdl=0 fdc=0 fdo+=jump,search:
3" vim:fdt=substitute(getline(v\:foldstart),'\\(.\*\\){\\{3}','\\1',''):
4" Yasuhiro Matsumoto <mattn.jp@gmail.com>
5"**************************************************
6
7"**************************************************
8"* Vim Environment {{{
9"--------------------------------------------------
10if $MSYSTEM != ''
11  finish
12endif
13if &compatible==1
14  set nocompatible
15endif
16set cmdheight=2
17set ignorecase
18set smartcase
19set tabstop=4
20set shiftwidth=4
21set history=50
22set noexpandtab
23set autoindent
24set backspace=indent,eol,start
25set wrapscan
26set noshowmatch
27set wildmenu
28set nonumber
29set ruler
30set nolist
31set listchars=tab:>-,trail:-,eol:\|
32set nowrap
33set laststatus=2
34set showcmd
35set noswapfile
36set nobackup
37set nohlsearch
38set cinoptions=>4
39set visualbell
40set incsearch
41set isprint=@,~-247,249-255
42set tags=./tags,tags,../tags
43if executable('grep')
44  if globpath(substitute($PATH, ';', ',', 'g'), 'grep.exe') =~ 'borland'
45    set grepprg=grep\ -no
46  else
47    set grepprg=grep\ -n
48  endif
49endif
50set shellslash
51if $SSH_CLIENT != ''
52  set clipboard=autoselect,exclude:cons\\\|linux\\\|cygwin\\\|rxvt\\\|screen\\\|xterm
53else
54  set clipboard=autoselect,exclude:cons\\\|linux\\\|cygwin\\\|rxvt\\\|screen
55endif
56set diffopt=filler,iwhite
57if has('unix') && $SHELL == ''
58  set shell=/bin/bash
59endif
60if $TERM=='jfbterm'
61  "fixdel
62endif
63"let $GTK_IM_MODULE = 'xim'
64"let $GDK_USE_XFT = 0
65" }}}
66"**************************************************
67
68" ignore bram's example script.
69let no_gvimrc_example=1
70let no_vimrc_example=1
71
72"**************************************************
73"* System Environment {{{
74"--------------------------------------------------
75if filereadable($VIM . '/vimrc') && filereadable($VIM . '/ViMrC')
76  set tags=./tags,tags
77endif
78
79if $HOME=='' && has('win32')
80  let $HOME=$USERPROFILE
81endif
82
83if $OSTYPE=='cygwin' || $TERM=='cygwin' || has('unix')
84  let $DESKTOP=$HOME.'/Desktop'
85else
86  let $DESKTOP=$USERPROFILE."/\x83\x66\x83\x58\x83\x4e\x83\x67\x83\x62\x83\x76"
87  if !isdirectory($DESKTOP)
88    let $DESKTOP=$USERPROFILE."/\xC3\xDE\xBD\xB8\xC4\xAF\xCC\xDF"
89  endif
90  let $MYDOCUMENT=$USERPROFILE.'/My Documents'
91endif
92
93" }}}
94"**************************************************
95
96"**************************************************
97"* Japanese Environment {{{
98"--------------------------------------------------
99if version >= 600
100  if has('win32')
101    " if using win32 ...
102    if $LANG=='' || ($OSTYPE=='cygwin' && $TERM=='cygwin')
103      let $LANG='ja'
104      set encoding=cp932
105      lang mes ja
106    endif
107  else
108    " if using cygwin console ...
109    if exists("$HOMEDRIVE")
110      set background=dark
111      if $LANG==''
112        let $LANG='ja_JP.SJIS'
113        set encoding=cp932
114      endif
115      if $TERM=='xterm-color' && !has('gui_running')
116        let $LANG='ja_JP.utf-8'
117        set encoding=utf-8
118        language ja_JP.utf-8
119        set langmenu=ja_jp.utf-8
120      elseif $LANG=='ja.SJIS' || $LANG=='ja_JP.SJIS'
121        set encoding=cp932
122        set langmenu=japanese_japan.932
123      else
124        set encoding=euc-jp
125        set langmenu=ja_jp.eucjp
126      endif
127    " if using unix console ...
128    elseif $TERM=='kon' || $TERM=='kterm'
129      if $LANG =~ 'UTF'
130        set termencoding=euc-jp
131        set ambiwidth=double
132      else
133        let $LANG='ja'
134        set encoding=euc-jp
135      endif
136    else
137      "let $LANG='ja'
138      "set langmenu=ja_jp.eucjp
139      "set encoding=eucjp
140    endif
141  endif
142endif
143
144if has('iconv')
145  let s:enc_euc = 'euc-jp'
146  let s:enc_jis = 'iso-2022-jp'
147  " check the supporting JISX0213 for iconv
148  if iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb"
149    let s:enc_euc = 'euc-jisx0213'
150    let s:enc_jis = 'iso-2022-jp-3'
151  endif
152  " build fileencodings
153  set fileencodings=iso-2022-jp-3,iso-2022-jp,euc-jisx0213,euc-jp,utf-8
154  set fileencodings+=utf-8
155  if &encoding =~# '^euc-\%(jp\|jisx0213\)$'
156    let &encoding = s:enc_euc
157    silent! let &encoding = 'eucjp-ms'
158  else
159    let &fileencodings = &fileencodings .','. s:enc_euc . ',eucjp-ms'
160  endif
161  set fileencodings+=cp932
162  unlet s:enc_euc
163  unlet s:enc_jis
164elseif executable('iconv')
165  function! CharConvert()
166    call system("iconv -f " . v:charconvert_from . " -t " . v:charconvert_to . " <" . v:fname_in . " >" . v:fname_out)
167    return v:shell_error
168  endfun
169  set charconvert=CharConvert()
170endif
171
172" if windows, detect mac format
173if $OSTYPE=='cygwin' || $TERM=='cygwin' || exists("$HOMEDRIVE")
174  set fileformats+=mac
175endif
176set fileformats+=mac
177
178" for printing
179if has('printer')
180  if has('win32')
181    set printfont=FixedSys:h10
182  elseif has("unix")
183    set printencoding=euc-jp
184    if exists('&printmbcharset')
185      set printmbcharset=JIS_X_1983
186      set printmbfont=r:Ryumin-Light,b:Ryumin-Light,a:yes,c:yes
187    endif
188  endif
189endif
190
191if exists('&formatoptions')
192  set formatoptions+=mB
193  let format_join_spaces=2
194  let format_allow_over_tw=1
195endif
196
197if exists('&ambiwidth') && (has('gui_running') || $TERM=="cygwin")
198  " some xterm don't support cjk width
199  set ambiwidth=double
200endif
201" }}}
202"**************************************************
203
204"**************************************************
205"* Key Maps {{{
206"--------------------------------------------------
207if !exists('g:mapleader')
208  " for all mapleader
209  let g:mapleader = '\'
210endif
211
212" expand path
213cmap <c-x> <c-r>=expand('%:p:h')<cr>/
214" expand file (not ext)
215cmap <c-z> <c-r>=expand('%:p:r')<cr>
216" try tab completion
217cmap <s-tab> <c-p>
218" like windows
219vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>
220vmap <tab> >gv
221vmap <s-tab> <gv
222" quit with no erase
223nmap <silent> gZZ :set t_te= t_ti= <cr>:quit<cr>:set t_te& t_ti&<cr>
224" shell with no erase
225nmap <silent> gsh :set t_te= t_ti= <cr>:sh<cr>:set t_te& t_ti&<cr>
226" for file complete
227cnoremap <c-g> <Space><BS>
228nmap te :tabedit<cr>
229nmap tc :tabclose<cr>
230
231if exists('&iminsert')
232  set iminsert=0
233  set imsearch=0
234  if !exists('&imoptions')
235    " for im_custom
236    inoremap <silent> <c-\> <c-o>:let &iminsert=(&iminsert==2?0:2)<cr>
237  endif
238endif
239
240" toggle list
241nmap <F2> :let &list=(&list == 1 ? 0 : 1)<cr>
242" rotate tab size
243nmap <silent> <F3> :let &ts=(&ts*2 > 16 ? 2 : &ts*2)<cr>:echo "tabstop:" . &ts<cr>
244" toggle highlight search
245nmap <F4> :let &hls=(&hls == 1 ? 0 : 1)<cr>
246" like visual studio
247nmap <F4> :copen<CR>\|:cnext<CR>
248" like visual studio
249nmap <S-F4> :copen<CR>\|:cprev<CR>
250" download
251nmap !D :exec "!wget " . expand('<cWORD>')<CR>
252
253function! Date()
254  return
255   \ strpart("SunMonTueWedThuFriSat", strftime("%w") * 3, 3).
256   \ strftime(", %d ").
257   \ strpart("JanFebMarAprMayJunJulAugSepOctNovDec", (strftime("%m")-1) * 3, 3).
258   \ strftime(" %Y")
259endfunction
260inoremap <m-d>  <c-r>=Date()<cr>
261" }}}
262"**************************************************
263
264"**************************************************
265"* Autocmd {{{
266"--------------------------------------------------
267autocmd BufNewFile,BufReadPost *.pc setf esqlc
268autocmd FileType jsp,asp,php,xml,perl syntax sync minlines=500 maxlines=1000
269autocmd FileType python setlocal ts=4 sw=4 sta et sts ai
270" }}}
271"**************************************************
272
273"**************************************************
274"* Syntax And Colorscheme {{{
275"--------------------------------------------------
276if isdirectory($VIMRUNTIME.'/syntax')
277  if &t_Co > 2 || has("gui_running")
278   syntax on
279  endif
280  if has("autocmd")
281    filetype plugin indent on
282  endif
283  autocmd BufReadPost *
284    \ silent! if line("'\"") > 0 && line("'\"") <= line("$") |
285    \   exe "normal g`\"" |
286    \ endif
287endif
288" colorscheme
289if has("gui_running")
290  colorscheme rainbow_autumn
291else
292  if $TERM=='rxvt'
293    silent! colorscheme blue
294  elseif $TERM=='cygwin'
295    silent! colorscheme autumn
296  else
297    silent! colorscheme torte
298  endif
299endif
300" }}}
301"**************************************************
302
303scriptencoding utf-8
304
305"**************************************************
306"* Script Parameters {{{
307"--------------------------------------------------
308" for menu.vim
309menutranslate Plugin プラグイン(&P)
310
311" for 2html.vim
312let g:use_xhtml = 1
313let g:html_use_css = 1
314let g:html_no_pre = 1
315
316" calenar.vim
317let g:calendar_erafmt = '平成,-1988'
318let g:calendar_mruler =
319 \'睦月,如月,弥生,卯月,皐月,水無月'.
320 \',文月,葉月,長月,神無月,霜月,師走'
321let g:calendar_wruler = '日 月 火 水 木 金 土'
322let g:calendar_weeknm = 4
323let g:calendar_navi_label = '前月,今月,次月'
324
325let g:calendar_diary = "~/.vim_diary"
326let g:calendar_mark = 'left'
327let g:calendar_navi = 'both'
328
329"* taglist.vim
330autocmd CursorHold __Tag_List__ normal p
331let g:icomplete_loaded = 1
332" }}}
333"**************************************************
Note: See TracBrowser for help on using the browser.