-
Notifications
You must be signed in to change notification settings - Fork 0
/
_vimrc
533 lines (423 loc) · 12.9 KB
/
_vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
"如果有这行 每行后面会有^m set fileformats=unix
set encoding=utf-8
"解决乱码
set ffs=unix,dos,mac " favor unix ff, which behaves good under bot Winz & Linux
set fencs=utf-8,ucs-bom,euc-jp,gb18030,gbk,gb2312,cp936
set fenc=utf-8
if has('win32')
set termencoding=chinese
language message zh_CN.UTF-8
endif
"自动加载 修改后自动生效 不需要重启 autoload _vimrc
" Automatic updating vimrc
autocmd! BufWritePost $MYVIMRC source %
filetype plugin on
filetype plugin indent on
""""""normal syntax settings begin
"Toggle Menu and Toolbar
set guioptions-=m
set guioptions-=T
"map <silent> <F1> :if &guioptions =~# 'T' <Bar>
" \set guioptions-=T <Bar>
" \set guioptions-=m <bar>
" \else <Bar>
" \set guioptions+=T <Bar>
" \set guioptions+=m <Bar>
" \endif<CR>
" Enable syntax highlight
syntax enable
" 关闭 vi 兼容模式
set nocompatible
" 突出显示当前行
"set cursorline
" Show line number
set nu
set autochdir
" 关闭声音
set noerrorbells
set novisualbell
set t_vb=
set tm=500
set visualbell
" show matching bracets
set showmatch
" Basic editing options
set expandtab
set shiftwidth=4
set softtabstop=4
"au FileType html,python,vim,javascript setl shiftwidth=4
"au FileType html,python,vim,javascript setl tabstop=4
"au FileType java,php setl shiftwidth=4
"au FileType java,php setl tabstop=4
"au FileType snippets setl tabstop=8
au FileType css,scss setl shiftwidth=4
au FileType css,scss setl tabstop=4
autocmd FileType python setlocal et sta sw=4 sts=4
"自动保存
au InsertLeave *.php write
au InsertLeave *.py write
set smarttab
set lbr
set tw=0
"Auto indent
set ai
" Smart indet
set smartindent
" C-style indeting
"set cindent
" Wrap lines
set wrap
"继承前一行的缩进方式,特别适用于多行注释
"set autoindent
"显示括号匹配
set showmatch
"括号匹配显示时间为1(单位是十分之一秒)
set matchtime=1
"上述设置启用了格式化高亮、行号显示,以及括号匹配、自动缩进等编辑功能,对于大多数情况都可以获得理想的编辑体验。不过此时对 .php 文件的支持还不完善,需要下载专门的 php 插件。
" Sets how many lines of history VIM har to remember
set history=400
" Set to auto read when a file is changed from the outside
set autoread
" Have the mouse enabled all the time:
set mouse=a
" Do not redraw, when running macros.. lazyredraw
set lz
" set 7 lines to the curors - when moving vertical..
set so=7
" The commandbar is 2 high
set cmdheight=2
" Change buffer - without saving
set hid
" Ignore case when searching
" set ignorecase
set incsearch
"将搜索的结果高亮显示,将十分的直观
"开启:
set hlsearch
" Set magic on
set magic
" No sound on errors.
set noerrorbells
set novisualbell
set t_vb=
" How many tenths of a second to blink
set mat=4
" Highlight search things
set hlsearch
" Turn backup on
set backup
set backupdir=F:/backup/vim
autocmd BufWritePre * let &backupext = '.' . strftime("%Y%m%d%H%M%S") . '.bak'
set nowb
set noswapfile
" smart backspace
set backspace=start,indent,eol
" switch buffers with Tab
"map <C-Tab> :bn<CR>
"map <S-Tab> :bp<CR>
" <leader>
let mapleader=","
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"常规界面设置
if has("gui_running")
set columns=110 " 设置宽
set lines=35 " 设置长
endif
colorscheme symfony
" font settings
set guifont=Bitstream\ Vera\ Sans\ Mono:h12:w7
"fullscreen
au GUIEnter * simalt ~x
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"自动补全括号 引号
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {<CR>}<Esc>O
autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=CloseBracket()<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>
fun! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
fun! CloseBracket()
if match(getline(line('.') + 1), '\s*}') < 0
return "\<CR>}"
else
return "\<Esc>j0f}a"
endif
endf
fun! QuoteDelim(char)
let line = getline('.')
let col = col('.')
if line[col - 2] == "\\"
"Inserting a quoted quotation mark into the string
return a:char
elseif line[col - 1] == a:char
"Escaping out of the string
return "\<Right>"
else
"Starting a string
return a:char.a:char."\<Esc>i"
endif
endf
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"一些tools设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Vundle
"filetype off
"set rtp+=$VIM./vimfiles/bundle/vundle/
"call vundle#rc('$VIM/vimfiles/bundle/')
"
"" Let Vundle manage Vundle
"Bundle 'gmarik/vundle'
"Bundle 'bufexplorer.zip'
"Bundle 'closetag.vim'
"Bundle 'scrooloose/nerdtree'
"Bundle 'DoxygenToolkit.vim'
"Bundle 'JavaScript-Indent'
"Bundle 'indentpython.vim'
"Bundle 'Lokaltog/vim-powerline.git'
"Bundle 'L9'
"Bundle 'neocomplcache'
"Bundle 'snipMate'
"Bundle 'unite.vim'
filetype plugin indent on
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"pathogen
call pathogen#infect()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" AutoComplPop
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" neocomplcache
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
let g:neocomplcache_enable_auto_select = 1
" snipMate
let g:neocomplcache_snippets_dir='$VIM/bundle/snipMate/snippets'
" When you input 'ho-a',neocomplcache will select candidate 'a'. 使用unite实现 因最新版的已不支持此特性
"let g:neocomplcache_start_unite_quick_match = 1
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
imap <C-k> <Plug>(neocomplcache_snippets_expand)
smap <C-k> <Plug>(neocomplcache_snippets_expand)
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
"imap <expr> - pumvisible() ?
" \ "\<Plug>(neocomplcache_start_unite_quick_match)" : '-'
" SuperTab like snippets behavior.
"imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()
" AutoComplPop like behavior.
"let g:neocomplcache_enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<TAB>"
"inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
"autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BufExplorer
map <C-F4> :BufExplorer<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" L9
let g:acp_ignorecaseOption = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERD Tree
let NERDChristmasTree=1
let NERDTreeAutoCenter=1
let NERDTreeBookmarksFile=$VIM.'\Data\NerdBookmarks.txt'
let NERDTreeMouseMode=2
let NERDTreeShowBookmarks=1
let NERDTreeShowFiles=1
let NERDTreeShowHidden=1
let NERDTreeShowLineNumbers=1
let NERDTreeWinPos='left'
let NERDTreeWinSize=28
nnoremap tree :NERDTreeToggle
"默认打开 NERD Tree
"autocmd VimEnter * NERDTree
"默认新标签页打开 NERD Tree
"autocmd BufRead * 25vsp ./
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"closetag settings
""使用CTRL-_
let g:closetag_html_style=1
au Filetype html,xml,xsl source $VIM/vimfiles/bundle/closetag/closetag.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"doxygen toolkit
let g:DoxygenToolkit_briefTag_pre = "@brief "
let g:DoxygenToolkit_paramTag_pre="@param "
let g:DoxygenToolkit_returnTag="@returns "
let g:DoxygenToolkit_licenseTag="GPL 2.0"
let g:DoxygenToolkit_authorName="sunhuai([email protected])"
map <C-F1> :DoxLic<cr>
map <C-F2> :DoxAuthor<cr>
map <C-F3> :Dox<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"VCS
"设置 <leader> 标签 VCS 的快捷键即可用,试试,cc
" <Leader>ca VCSAdd
" <Leader>cn VCSAnnotate
" <Leader>cN VCSAnnotate!
" <Leader>cc VCSCommit
" <Leader>cD VCSDelete
" <Leader>cd VCSDiff
" <Leader>cg VCSGotoOriginal
" <Leader>cG VCSGotoOriginal!
" <Leader>ci VCSInfo
" <Leader>cl VCSLog
" <Leader>cL VCSLock
" <Leader>cr VCSReview
" <Leader>cs VCSStatus
" <Leader>cu VCSUpdate
" <Leader>cU VCSUnlock
" <Leader>cv VCSVimDiff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"map settings
"复制当前路径到剪切板
map <F1> : call CurrentPath()<cr>
fun! CurrentPath()
let path = expand('%:p')
let @+ = substitute(path, '\', '/', 'g')
endf
"一键复制到剪切板
"map <F11> : "*y<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"针对不同变成语言所做的配置 below
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Taglist
"注意ctags的路径
""let Tlist_Auto_Open = 1
if has('win32')
let Tlist_Ctags_Cmd = $VIM . '/vimfiles/others/ctags/ctags.exe'
endif
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
"let Tlist_Auto_Open=1
map <F10> : Tlist<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"C
"语言编译工具函数配置
fun! CompileRun()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc -Wl,-enable-auto-import % -g -o %<.exe"
"c++程序
elseif &filetype == 'cpp'
exec "!g++ -Wl,-enable-auto-import % -g -o %<.exe"
endif
endf
"结束定义CompileRun
"定义Run函数
fun! Run()
if &filetype == 'c' || &filetype == 'cpp'
exec "!%<.exe"
endif
endf
"结束定义Run
"定义Debug函数,用来调试程序
fun! Debug()
exec "w"
"C程序
if &filetype == 'c'
exec "!gcc % -g -o %<.exe"
exec "!gdb %<.exe"
elseif &filetype == 'cpp'
exec "!g++ % -g -o %<.exe"
exec "!gdb %<.exe"
endif
endf
"结束定义Debug
map <F4> :call CompileRun()<CR>
map <F5> :call Debug()<CR>
map <F6> :call Run()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Go
"语言编译工具函数配置
fun! GoRun()
if &filetype == 'go'
exec "!go run %"
endif
endf
"结束定义CompileRun
map <F9> :call GoRun()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"python
"语言编译工具函数配置
fun! PythonRun()
exec "!python.exe %"
endf
"map <F2> :!python.exe %<CR>
map <F3> :call PythonRun()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"php
fun! PhpRun()
exec "!php.exe %"
endf
map <F2> :call PhpRun()<CR>
fun! PhpSyntaxValid()
exec "!php.exe -l %"
endf
map <F7> :call PhpSyntaxValid()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"JavaScript
"配置缩进插件
let g:SimpleJsIndenter_BriefMode = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Zend Coding
"HTML CSS
"配置缩进插件
let g:user_zen_leader_key = '<c-m>'