1 if v:version < 700
2 echoerr 'This _vimrc requires Vim 7 or later.'
3 quit
4 endif
5
6
7
8
9 if has("win32")
10 autocmd! bufwritepost _vimrc source %
11 autocmd! bufwritepost .vimrc source %
12 set guifont=Consolas:h14:cANSI
13 set rtp+=$HOME/.vim/*
14 else
15 autocmd! bufwritepost .vimrc source %
16 set guifont=Consolas\ 13
17 endif
18
19
20
21 :source $VIMRUNTIME/ftplugin/man.vim
22
23
24
25 set go=tm
26 set helplang=cn
27 set history=500
28 set nocompatible
29
30 set wrap
31 set linebreak
32 set tabpagemax=15
33 set showtabline=1
34 set noerrorbells
35 set novisualbell
36 set t_vb=
37 filetype plugin indent on
38 set ruler
39 set number
40 set numberwidth=4
41 set rulerformat=%15(%c%V\ %p%%%)
42 set t_Co=256
43 set cmdheight=1
44 set laststatus=2
45 set scrolloff=2
46 au FileType c,cpp set cc=81
47 set showcmd
48 set cursorline
49
50 set nohlsearch
51 set incsearch
52 set magic
53 set showmatch
54 set mat=2
55 set tabstop=4
56 set shiftwidth=4
57 set softtabstop=4
58 set expandtab
59 set smarttab
60
61 set listchars=tab:\|\ ,nbsp:%,trail:-
62 set autoindent
63 set smartindent
64 set cin
65 set autoread
66 set mouse=a
67 set backspace=indent,eol,start
68 set nobackup
69 set nowb
70 set noswapfile
71 set complete=.,w,b,k,t,i
72 set completeopt=longest,menu
73 set wildmenu
74 set foldnestmax=2
75
76 set foldopen=all
77 set foldclose=all
78 set foldlevel=100
79 set foldmethod=marker
80 set foldmethod=syntax
81 set bsdir=buffer
82 set autochdir
83
84
85
86 func! ShortTabLabel()
87 let bufnrlist = tabpagebuflist(v:lnum)
88 let label = bufname(bufnrlist[tabpagewinnr(v:lnum) -1])
89 let filename = fnamemodify(label, ':t')
90 return filename
91 endfunc
92 set guitablabel=%{ShortTabLabel()}
93 set stl=\ [File]\ %F%m%r%h%y[%{&fileformat},%{&fileencoding}]\ %w\ [PATH]\ %{getcwd()}%h\ %=\ [line]%l/%L\ [col]%c/%V
94
95
96
97
98 if has("multi_byte")
99 set encoding=utf-8
100 let &termencoding=&encoding
101 set fileencodings=utf-8,cp936,gb2312,gbk,gb18030,ucs-2le,chinese
102 set fileformats=unix,dos
103 au BufRead * set fileencodings=utf-8,cp936,gb2312,gbk,gb18030,ucs-2le,chinese
104 au BufRead * set fileformats=unix,dos
105
106 if has('win32')
107 source $VIMRUNTIME/delmenu.vim
108 source $VIMRUNTIME/menu.vim
109 endif
110
111 set fileencoding=utf-8
112 language messages zh_CN.utf-8
113 set formatoptions+=mM
114 set nobomb
115 if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
116 set ambiwidth=double
117 endif
118 else
119 echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
120 endif
121
122
123
124
125 function! ClosePair(char)
126 if getline('.')[col('.') - 1] == a:char
127 return "\<Right>"
128 else
129 return a:char
130 endif
131 endf
132
133 function! CloseBracket()
134 if match(getline(line('.') + 1), '\s*}') < 0
135 return "\<CR>}"
136 else
137 return "\<Esc>j0f}a"
138 endif
139 endf
140
141 function! QuoteDelim(char)
142 let line = getline('.')
143 let col = col('.')
144 if line[col - 2] == "\\"
145
146 return a:char
147 elseif line[col - 1] == a:char
148
149 return "\<Right>"
150 else
151
152 return a:char.a:char."\<Esc>i"
153 endif
154 endf
155
156 if has("autocmd")
157 inoremap [ []<Esc>i
158 inoremap { {<CR>}<Esc>O
159 autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
160 inoremap ] <c-r>=ClosePair(']')<CR>
161 inoremap } <c-r>=CloseBracket()<CR>
162 inoremap " <c-r>=QuoteDelim('"')<CR>
163 inoremap ' <c-r>=QuoteDelim("'")<CR>
164 endif
165
166
167
168
169
170 let mapleader = ","
171 let g:mapleader = ","
172
173 nmap <leader>s :w!<cr>
174 nmap <leader>w :wq!<cr>
175
176 nmap <leader>tt :tabnew .<cr>
177 nmap <leader>tc :tabclose<cr>
178
179
180
181
182
183
184
185
186 let g:C_LineEndCommColDefault = 80
187 let g:Templates_MapInUseWarn = 0
188
189
190
191
192 let g:OmniCpp_ShowPrototypeInAbbr = 1
193 let g:OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
194 let g:OmniCpp_SelectFirstItem = 1
195
196
197
198 let g:OmniCpp_NamespaceSearch = 2
199
200
201
202
203 let g:xptemplate_key = '<leader><Tab>'
204
205
206
207
208 let g:completekey = "<Tab>"
209
210
211
212
213 let g:SuperTabRetainCompletionType=2
214 let g:SuperTabDefaultCompletionType="context"
215
216
217
218
219 map ca :Calendar<cr>
220
221
222
223
224
225
226
227 function! Do_CsTag()
228 let dir = getcwd()
229
230 if(executable('ctags'))
231 if filereadable("../tags")
232 if has('win32')
233 silent! execute "let NOWDIR=getcwd()|cd ../"
234 silent! execute "!gentags.bat"
235 silent! execute "cd NOWDIR"
236 else
237 silent! execute "!NOWDIR=$(pwd);cd ../;ctags -R --c-types=+p --fields=+lS $(pwd)/;cd $NOWDIR"
238 silent! execute "!NOWDIR=$(pwd);cd ../;ctags -R --c++-kinds=+p --fields=+iaS --extra=+q $(pwd)/;cd $NOWDIR"
239 silent! execute "!NOWDIR=$(pwd);cd ../;ctags -R --extra=+q $(pwd)/;cd $NOWDIR"
240 endif
241 set tags+=../tags
242 else
243 if has('win32')
244 silent! execute "!gentags.bat"
245 else
246 if ( &filetype == "c" )
247 silent! execute "!ctags -R --recurse=yes --c-types=+p --fields=+lS $(pwd)/"
248 elseif ( &filetype == "cpp" )
249 silent! execute "!ctags -R --recurse=yes --c++-kinds=+p --fields=+iaS --extra=+q $(pwd)/"
250 else
251 silent! execute "!ctags -R --extra=+q $(pwd)/"
252 endif
253 endif
254 set tags+=./tags,tags
255 endif
256 endif
257
258 if (executable('cscope') && has("cscope") )
259 silent! execute "cs kill -1"
260 if ( filereadable("../cscope.out") )
261 if has('win32')
262 silent! execute "let NOWDIR=getcwd()|cd ../"
263 silent! execute "!gencscope.bat"
264 silent! execute "cd NOWDIR"
265 else
266 silent! execute "!NOWDIR=$(pwd);cd ../;find $(pwd)/ -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' -o -name '*.js' -o -name '*.html' >$(pwd)/cscope.files;cscope -Rbqk 2>/dev/null >&1 ;cd $NOWDIR"
267 endif
268 execute "normal :"
269 set nocsverb
270 exec "cs add ../cscope.out"
271 set csverb
272 else
273 if has('win32')
274 silent! execute "!gencscope.bat"
275 else
276 silent! execute "!find $(pwd)/ -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' -o -name '*.js' -o -name '*.html' >$(pwd)/cscope.files"
277 silent! execute "!cscope -Rbqk 2>/dev/null >&1 "
278 endif
279 execute "normal :"
280 set nocsverb
281 exec "cs add cscope.out"
282 set csverb
283 endif
284 endif
285 endf
286
287
288 func! TagConf()
289 if ( &filetype == "c" )
290 let g:Tlist_Inc_Winwidth=0
291 let g:Tlist_Use_Right_Window=1
292 let g:Tlist_File_Fold_Auto_Close=1
293 let g:Tlist_Auto_Highlight_Tag = 1
294 let g:Tlist_Auto_Open = 0
295 let g:Tlist_Auto_Update = 1
296 let g:Tlist_Close_On_Select = 0
297 let g:Tlist_Compact_Format = 1
298 let g:Tlist_Display_Prototype = 0
299 let g:Tlist_Display_Tag_Scope = 1
300 let g:Tlist_Enable_Fold_Column = 0
301 let g:Tlist_Exit_OnlyWindow = 1
302 let g:Tlist_Show_One_File = 1
303 let g:Tlist_GainFocus_On_ToggleOpen = 1
304 let g:tlist_php_settings = 'php;c:class;i:interfaces;d:constant;f:function'
305 exec "TlistToggle"
306 else
307 exec "TagbarToggle"
308
309 endif
310 endfunc
311
312 let Tlist_Use_Right_Window=1
313 if filereadable("../tags")
314 set tags+=../tags
315 else
316 set tags+=./tags,tags
317 endif
318
319 if (executable('cscope') && has("cscope") )
320 silent! execute "cs kill -1"
321 if ( filereadable("../cscope.out") )
322 set nocsverb
323 exec "cs add ../cscope.out"
324 set csverb
325 else
326 set nocsverb
327 exec "cs add cscope.out"
328 set csverb
329 endif
330 endif
331 set tags+=$HOME/.vim/systags
332 set tags+=$HOME/.vim//stl/stl.tags
333 set csprg=/usr/bin/cscope
334 set cst
335 set csto=1
336
337
338
339
340
341
342
343
344 nmap <leader>ss :cs find s <C-R>=expand("<cword>")<CR><CR>
345 nmap <leader>sg :cs find g <C-R>=expand("<cword>")<CR><CR>
346 nmap <leader>sc :cs find c <c-r>=expand("<cword>")<cr><cr>
347 nmap <leader>st :cs find t <C-R>=expand("<cword>")<CR><CR>
348 nmap <leader>se :cs find e <C-R>=expand("<cword>")<CR><CR>
349 nmap <leader>sf :cs find f <C-R>=expand("<cfile>")<CR><CR>
350 nmap <leader>si :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
351 nmap <leader>sd :cs find d <C-R>=expand("<cword>")<CR><CR>
352 au bufwritepost *.c,*.cpp,*.h,*.java,*.html,*.js,*.php call Do_CsTag()
353
354 map <F2> :call Do_CsTag()<cr>:redraw!<cr>
355
356
357
358
359 let g:winManagerWidth=25
360 function! BufExplorer()
361 call BufExplorer(...)
362 endfunction
363 let g:winManagerWindowLayout = 'FileExplorer|BufExplorer'
364 map <F3> :WMToggle<cr>
365
366
367
368
369 map <F4> :call TagConf()<cr>
370
371
372
373
374 let g:LookupFile_TagExpr = '"tags"'
375
376
377
378
379 let g:fencview_autodetect=1
380 map <F6> :FencView<cr>
381
382
383
384
385
386
387
388 func! FormartSrc()
389 exec "w"
390 if &filetype == 'c'
391 exec "!astyle --style=ansi -U -p --break-elseifs --suffix=none %"
392 exec "e! %"
393 elseif &filetype == 'cpp'
394 exec "!astyle -q --style=ansi -U -P --break-elseifs --suffix=none %"
395 exec "e! %"
396 elseif &filetype == 'java'
397 exec "!astyle --style=java --suffix=none %"
398 exec "e! %"
399 else
400 exec "!astyle --style=ansi --suffix=none %"
401 exec "e! %"
402 endif
403 return
404 endfunc
405 if has('unix')
406 map <F7> :call FormartSrc()<cr><cr>
407 endif
408
409
410
411
412
413 let g:checksyntax_key_single = '<C-F8>'
414 let g:checksyntax_key_all = '<F8>'
415
416 let g:syntastic_check_on_open = 1
417
418 let g:syntastic_auto_jump = 0
419 let g:syntastic_always_populate_loc_list = 1
420 let g:syntastic_auto_loc_list = 1
421 let g:syntastic_error_symbol = '✗'
422 let g:syntastic_warning_symbol = '⚠'
423
424
425
426
427 let g:groj_flags='scL'
428 nmap <silent><F10> <PLUG>ToggleProject
429
430
431
432
433
434
435
436
437
438
439
440 let g:Doxy_FormatDate= '%D'
441 let g:Doxy_FormatTime= '%T'
442 let g:Doxy_FormatYear= '%Y'
443 imap <leader>dfh <ESC>:DoxyFILEHeader<cr>
444 imap <leader>dbl <ESC>:DoxyBlockLong<cr>
445 imap <leader>dbs <ESC>:DoxyBlockShort<cr>
446 imap <leader>dfc <ESC>:DoxyFunction<cr>
447 imap <leader>dcl <ESC>:DoxyClass<cr>
448
449
450
451
452 let tlist_vimwiki_settings = 'wiki;h:Headers'
453 let g:vimwiki_camel_case = 0
454 let g:vimwiki_hl_cb_checked = 1
455
456 let g:vimwiki_folding = 1
457 let g:vimwiki_CJK_length = 1
458 let g:vimwiki_valid_html_tags='b,i,s,u,sub,sup,kbd,del,br,hr,div,code,h1,pre'
459 let g:vimwiki_use_mouse = 1
460 let g:vimwiki_hl_cb_checked = 1
461 let g:vimwiki_calendar = 1
462 let g:vimwiki_auto_checkbox = 0
463 let g:vimwiki_html_header_numbering = 2
464 let privatewiki = {}
465 let sharewiki = {}
466 let sharewiki.index = 'index'
467 nmap <leader>va :VimwikiAll2HTML<cr>
468 let g:vimwiki_list=[privatewiki,sharewiki]
469
470 nmap <leader>vh :Vimwiki2HTML<cr>
471 nmap <leader>vb :Vimwiki2HTMLBrowse<cr>
472
473
474
475 au FileType vimwiki set ff=unix fenc=utf-8 noswapfile nobackup
476 au FIleType vimwiki set cursorcolumn
477
478
479
480
481 if has('syntax')
482 au BufNewFile,BufRead *.doxygen setfiletype doxygen
483
484 if has("win32")
485 au BufNewFile,BufRead,BufEnter,WinEnter * colo molokai
486 au BufNewFile,BufRead,BufEnter,WinEnter *.wiki colo molokai
487 else
488 au BufNewFile,BufRead,BufEnter,WinEnter * colo molokai
489 au BufNewFile,BufRead,BufEnter,WinEnter *.wiki colo molokai
490 endif
491 syntax on
492 endif
493
494
495
496
497
498 au FileType html,python,vim,javascript,tpl setl shiftwidth=2
499 au FileType html,python,vim,javascript,tpl setl tabstop=2
500 au FileType java,php setl shiftwidth=4
501 au FileType java,php setl tabstop=4
502
503
504
505
506 let g:user_zen_settings = {
507 \ 'php' : {
508 \ 'extends' : 'html',
509 \ 'filters' : 'c',
510 \ },
511 \ 'xml' : {
512 \ 'extends' : 'html',
513 \ },
514 \ 'haml' : {
515 \ 'extends' : 'html',
516 \ },
517 \}
518 let g:user_zen_expandabbr_key = '<Tab>'
519 let g:user_emmet_leader_key ="<C-e>"
520
521
522
523
524
525 set nocompatible
526 filetype off
527 set rtp+=$HOME/.vim/bundle/vundle/
528 call vundle#rc()
529 Bundle 'gmarik/vundle'
530
531 Bundle 'tomtom/checksyntax_vim'
532
533 Bundle 'scrooloose/nerdtree'
534
535 Bundle 'blak3mill3r/c.vim'
536
537 Bundle 'turing1988/ColorSamplerPack'
538
539 Bundle 'ervandew/supertab'
540
541 Bundle 'plasticboy/vim-markdown'
542
543 Bundle 'mattn/emmet-vim'
544
545 Bundle 'DoxyGen-Syntax'
546
547 Bundle 'LargeFile'
548
549 Bundle 'lookupfile'
550
551 Bundle 'xptemplate'
552
553 Bundle 'cecutil'
554
555 Bundle 'genutils'
556
557 Bundle 'calendar.vim--Matsumoto'
558
559 Bundle 'code_complete'
560
561 Bundle 'Color-Scheme-Explorer'
562
563 Bundle 'Mark'
564
565 Bundle 'Tagbar'
566
567 Bundle 'vimwiki'
568
569 Bundle 'winmanager'
570
571 Bundle 'OmniCppComplete'
572
573 Bundle 'a.vim'
574
575 Bundle 'bufexplorer.zip'
576
577 Bundle 'doxygen-support.vim'
578
579 Bundle 'FencView.vim'
580
581 Bundle 'fontsize.vim'
582
583 Bundle 'surround.vim'
584
585 Bundle 'taglist.vim'
586
587 Bundle 'vimcn/vimwiki.vim.cnx'
588
589 Bundle 'vimcn/tagbar.cnx'
590
591 Bundle 'vimcn/taglist.vim.cnx'
592
593 Bundle 'jkeylu/vimdoc_cn'
594
595 Bundle 'Valloric/ListToggle'
596
597 Bundle 'scrooloose/syntastic'
598 filetype plugin indent on
599
600