-
Notifications
You must be signed in to change notification settings - Fork 0
/
_vimrc
759 lines (619 loc) · 27.1 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
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
" -----------------------------------------------------------------------------
" < Judge current OS is Windows or Linux >
" -----------------------------------------------------------------------------
if(has("win32") || has("win64") || has("win95") || has("win16"))
let g:iswindows = 1
else
let g:iswindows = 0
endif
" -----------------------------------------------------------------------------
" < Judge current process is vim or gvim >
" -----------------------------------------------------------------------------
if has("gui_running")
let g:isGUI = 1
else
let g:isGUI = 0
endif
"============================================
" => General
"============================================
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
" Disable vi no compatible
set nocompatible
" Sets how many lines of history Vim has to remember
set history=1000
" Enable spell on
"set spell
" Set to auto read when a file is changed from the outside
set autoread
" Hide startup message
set shortmess+=atI
" Better Unix/windows compatible (maybe)
set viewoptions=folds,options,cursor,unix,slash
" Allow for cursor beyond last character
set virtualedit=onemore
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let manleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Fast edit _vimrc and auto reload new vimrc after saved
if g:iswindows
map <silent> <leader>ee :e $VIM/_vimrc<cr>
autocmd! bufwritepost _vimrc source $VIM/_vimrc
else
map <silent> <leader>ee :e $HOME/.vimrc<cr>
autocmd! bufwritepost *.vimrc source $HOME/.vimrc
endif
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" =========================================================================
" => Vim user interface
" =========================================================================
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Enable file type check
filetype plugin indent on
" Turn on the Wild menu
set wildmenu
" Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros good setting!!!!!!!!!!!!
"set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" set status line
set laststatus=2
" Add a bit extra margin to left
set foldcolumn=2
" Show and hide menu/tool/scrool, switch for Ctrl + F11
if g:isGUI
set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions-=L
set guioptions+=b
set guioptions+=r
map <silent> <c-F11> :if &guioptions =~# 'm' <Bar>
\set guioptions-=m <Bar>
\set guioptions-=T <Bar>
\set guioptions-=r <Bar>
\set guioptions-=L <Bar>
\else <Bar>
\set guioptions+=m <Bar>
\set guioptions+=T <Bar>
\set guioptions+=r <Bar>
\set guioptions+=L <Bar>
\endif<CR>
" Set no warp if line too long
set nowrap
endif
" Show line number
set number
" Show current line
set cursorline
" Set maxium in startup
au GUIEnter * simalt ~x
" Set startup pos
winpos 300 30
" Set startup window size
set lines=38 columns=120
" status line scheme
let &statusline=' %t %{&mod?(&ro?"*":"+"):(&ro?"=":" ")} %1*|%* %{&ft==""?"any":&ft} %1*|%* %{&ff} %1*|%* %{(&fenc=="")?&enc:&fenc}%{(&bomb?",BOM":"")} %1*|%* %=%1*|%* 0x%B %1*|%* (%l,%c%V) %1*|%* %L %1*|%* %P'
"set statusline=%t\ %1*%m%*\ %1*%r%*\ %2*%h%*%w%=%l%3*/%L(%p%%)%*,%c%V]\ [%b:0x%B]\ [%{&ft==''?'TEXT':toupper(&ft)},%{toupper(&ff)},%{toupper(&fenc!=''?&fenc:&enc)}%{&bomb?',BOM':''}%{&eol?'':',NOEOL'}]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" Set the font and size
set guifont=YaHei_Consolas_Hybrid:h12
" Set color scheme
if g:isGUI
set background=dark
if filereadable(expand("$VIM/vimfiles/bundle/vim-colors-solarized/colors/solarized.vim"))
let g:solarized_termcolors=256
let g:solarized_termtrans=1
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
color solarized
endif
else
colorscheme Tomorrow-Night-Eighties
endif
if (g:iswindows && g:isGUI)
source $VIMRUNTIME/mswin.vim
behave mswin
endif
if !g:iswindows
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
if g:isGUI
" Source a global configuration file if available
if filereadable("/etc/vim/gvimrc.local")
source /etc/vim/gvimrc.local
endif
else
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
set mouse=a " 在任何模式下启用鼠标
set t_Co=256 " 在终端启用256色
set backspace=2 " 设置退格键可用
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
endif
endif
"======================================================================
" => encoding
"======================================================================
" Set gvim encoding
set encoding=utf-8
" Set current file encoding
set fileencoding=utf-8
" Set support to file encoding
set fileencodings=ucs-bom,utf-8,gbk,cp936,latin-1
" file format
set fileformat=unix
set fileformats=unix,dos,mac
if (g:iswindows && g:isGUI)
" fix menu messy code
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" fix messy code
language messages zh_CN.utf-8
endif
" -----------------------------------------------------------------------------
" => Files, backup and undo
" -----------------------------------------------------------------------------
" no backup file
set nobackup
" set no write backup file
set nowb
" set no swap file
set noswapfile
" -----------------------------------------------------------------------------
" Editing setting
" -----------------------------------------------------------------------------
" Enable auto indent
set autoindent
" Enable smart indent
set smartindent
" Enable C format imdent
set cindent
" Change tab to space
set expandtab
" Set tab to 4 char wide
set tabstop=4
" Set auto indent for 4 spaces to warp
set shiftwidth=4
" Enable smart tab for use backspace delete
set smarttab
" Enable fold
"set foldenable
" fold mode
"set foldmethod=indent
" set foldmethod=marker
" Use space to switch fold
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" Clear spaces at the end in normal mode
nmap cS :%s/\s\+$//g<cr>:noh<cr>
" Clear ^M at the end in normal mode
nmap cM :%s/\r$//g<cr>:noh<cr>
" ignore case for search mode
set ignorecase
" if searching upcase char, don't use ignorecase, useful just set ignorecase
set smartcase
" Move up for insert mode
imap <c-k> <Up>
" Move down for insert mode
imap <c-j> <Down>
" Move left for insert mode
imap <c-h> <Left>
" Move right for insert mode
imap <c-l> <Right>
" Disable highlight when <leader><cr> is pressed
map <silent> <leader>, :nohlsearch<cr>
" Add underline to over 80 char each line
au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 80 . 'v.\+', -1)
" =========================================================================
" => Windows and buffers
" =========================================================================
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,1000 bd!<cr>
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
" < Vundle 插件管理工具配置 >
" -----------------------------------------------------------------------------
" 用于更方便的管理vim插件,具体用法参考 :h vundle 帮助
" 安装方法为在终端输入如下命令
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
filetype off
if !g:iswindows
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
else
set rtp+=$VIM/vimfiles/bundle/vundle/
call vundle#rc('$VIM/vimfiles/bundle/')
endif
" Use Vundle to manager Vundle, It's required!
Bundle 'gmarik/vundle'
" 以下为要安装或更新的插件,不同仓库都有(具体书写规范请参考帮助)
"Bundle 'a.vim'
"Bundle 'Align'
"Bundle 'jiangmiao/auto-pairs'
Bundle 'bufexplorer.zip'
"Bundle 'ccvext.vim'
Bundle 'cSyntaxAfter'
"Bundle 'Yggdroot/indentLine'
Bundle 'Mark--Karkat'
Bundle 'minibufexpl.vim'
Bundle 'Shougo/neocomplcache.vim'
Bundle 'https://github.com/Shougo/neocomplcache.vim.git'
Bundle 'scrooloose/nerdcommenter'
Bundle 'scrooloose/nerdtree'
Bundle 'ervandew/supertab'
Bundle 'std_c.zip'
"Bundle 'tpope/vim-surround'
"Bundle 'scrooloose/syntastic'
Bundle 'majutsushi/tagbar'
Bundle 'taglist.vim'
"Bundle 'TxtBrowser'
Bundle 'winmanager'
Bundle 'ZoomWin'
" color scheme
Bundle 'git://github.com/altercation/vim-colors-solarized.git'
" status line plugin
"Bundle "Lokaltog/vim-powerline"
filetype plugin indent on
" =============================================================================
" << 以下为常用插件配置 >>
" =============================================================================
" -----------------------------------------------------------------------------
" < a.vim 插件配置 >
" -----------------------------------------------------------------------------
" 用于切换C/C++头文件
" :A ---切换头文件并独占整个窗口
" :AV ---切换头文件并垂直分割窗口
" :AS ---切换头文件并水平分割窗口
" -----------------------------------------------------------------------------
" < Align 插件配置 >
" -----------------------------------------------------------------------------
" 一个对齐的插件,用来——排版与对齐代码,功能强大,不过用到的机会不多
" -----------------------------------------------------------------------------
" < auto-pairs 插件配置 >
" -----------------------------------------------------------------------------
" 用于括号与引号自动补全,不过会与函数原型提示插件echofunc冲突
" 所以我就没有加入echofunc插件
" -----------------------------------------------------------------------------
" < BufExplorer 插件配置 >
" -----------------------------------------------------------------------------
" 快速轻松的在缓存中切换(相当于另一种多个文件间的切换方式)
" <Leader>be 在当前窗口显示缓存列表并打开选定文件
" <Leader>bs 水平分割窗口显示缓存列表,并在缓存列表窗口中打开选定文件
" <Leader>bv 垂直分割窗口显示缓存列表,并在缓存列表窗口中打开选定文件
" -----------------------------------------------------------------------------
" < ccvext.vim 插件配置 >
" -----------------------------------------------------------------------------
" 用于对指定文件自动生成tags与cscope文件并连接
" 如果是Windows系统, 则生成的文件在源文件所在盘符根目录的.symbs目录下(如: X:\.symbs\)
" 如果是Linux系统, 则生成的文件在~/.symbs/目录下
" 具体用法可参考www.vim.org中此插件的说明
" <Leader>sy 自动生成tags与cscope文件并连接
" <Leader>sc 连接已存在的tags与cscope文件
" -----------------------------------------------------------------------------
" < cSyntaxAfter 插件配置 >
" -----------------------------------------------------------------------------
" 高亮括号与运算符等
au! BufRead,BufNewFile,BufEnter *.{c,cpp,h,javascript} call CSyntaxAfter()
" -----------------------------------------------------------------------------
" < indentLine 插件配置 >
" -----------------------------------------------------------------------------
" 用于显示对齐线,与 indent_guides 在显示方式上不同,根据自己喜好选择了
" 在终端上会有屏幕刷新的问题,这个问题能解决有更好了
" 开启/关闭对齐线
"nmap <leader>il :IndentLinesToggle<CR>
" 设置Gvim的对齐线样式
"if g:isGUI
"let g:indentLine_char = "┊"
"let g:indentLine_first_char = "┊"
"endif
" 设置终端对齐线颜色
" let g:indentLine_color_term = 239
"
" 设置 GUI 对齐线颜色
" let g:indentLine_color_gui = '#A4E57E'
" -----------------------------------------------------------------------------
" < Mark--Karkat(也就是 Mark) 插件配置 >
" -----------------------------------------------------------------------------
" 给不同的单词高亮,表明不同的变量时很有用,详细帮助见 :h mark.txt
" " -----------------------------------------------------------------------------
" " < MiniBufExplorer Setting >
" " -----------------------------------------------------------------------------
let g:miniBufExplMapWindowNavArrows = 1 "用Ctrl加方向键切换到上下左右的窗口中去
let g:miniBufExplMapWindowNavVim = 1 "用<C-k,j,h,l>切换到上下左右的窗口中去
let g:miniBufExplMapCTabSwitchBufs = 1 "功能增强(不过好像只有在Windows中才有用)
" " <C-Tab> 向前循环切换到每个buffer上,并在但前窗口打开
" " <C-S-Tab> 向后循环切换到每个buffer上,并在当前窗口打开
" 在不使用 MiniBufExplorer 插件时也可用<C-k,j,h,l>切换到上下左右的窗口中去
noremap <c-k> <c-w>k
noremap <c-j> <c-w>j
noremap <c-h> <c-w>h
noremap <c-l> <c-w>l
" -----------------------------------------------------------------------------
" < neocomplcache 插件配置 >
" -----------------------------------------------------------------------------
" 关键字补全、文件路径补全、tag补全等等,各种,非常好用,速度超快。
let g:neocomplcache_enable_at_startup = 1 "vim 启动时启用插件
" let g:neocomplcache_disable_auto_complete = 1 "不自动弹出补全列表
" 在弹出补全列表后用 <c-p> 或 <c-n> 进行上下选择效果比较好
" -----------------------------------------------------------------------------
" < nerdcommenter 插件配置 >
" -----------------------------------------------------------------------------
" 我主要用于C/C++代码注释(其它的也行),这个插件我做了小点修改,也就是在注释符
" 与注释内容间加一个空格
" 以下为插件默认快捷键,其中的说明是以C/C++为例的
" <Leader>ci 以每行一个 /* */ 注释选中行(选中区域所在行),再输入则取消注释
" <Leader>cm 以一个 /* */ 注释选中行(选中区域所在行),再输入则称重复注释
" <Leader>cc 以每行一个 /* */ 注释选中行或区域,再输入则称重复注释
" <Leader>cu 取消选中区域(行)的注释,选中区域(行)内至少有一个 /* */
" <Leader>ca 在/*...*/与//这两种注释方式中切换(其它语言可能不一样了)
" <Leader>cA 行尾注释
let NERDSpaceDelims = 1 "在左注释符之后,右注释符之前留有空格
" -----------------------------------------------------------------------------
" < nerdtree 插件配置 >
" -----------------------------------------------------------------------------
" 常规模式下输入 F2 调用插件
nmap <F2> :NERDTreeToggle<CR>
let g:NERDTree_title='NERD Tree'
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
" -----------------------------------------------------------------------------
" < omnicppcomplete 插件配置 >
" -----------------------------------------------------------------------------
" 用于C/C++代码补全,这种补全主要针对命名空间、类、结构、共同体等进行补全,详细
" 说明可以参考帮助或网络教程等
" 使用前先执行如下 ctags 命令(本配置中可以直接使用 ccvext 插件来执行以下命令)
" ctags -R --c++-kinds=+p --fields=+iaS --extra=+q
" 我使用上面的参数生成标签后,对函数使用跳转时会出现多个选择
" 所以我就将--c++-kinds=+p参数给去掉了,如果大侠有什么其它解决方法希望不要保留呀
set completeopt=menu "关闭预览窗口
" -----------------------------------------------------------------------------
" < powerline plugin setting >
" -----------------------------------------------------------------------------
" a better status line plugin
"set t_Co=256
"let g:Powerline_symbols = 'fancy'
"let Powerline_symbols='compatible'
" -----------------------------------------------------------------------------
" < repeat 插件配置 >
" -----------------------------------------------------------------------------
" 主要用"."命令来重复上次插件使用的命令
" -----------------------------------------------------------------------------
" < snipMate 插件配置 >
" -----------------------------------------------------------------------------
" 用于各种代码补全,这种补全是一种对代码中的词与代码块的缩写补全,详细用法可以参
" 考使用说明或网络教程等。不过有时候也会与 supertab 插件在补全时产生冲突,如果大
" 侠有什么其它解决方法希望不要保留呀
" -----------------------------------------------------------------------------
" < SrcExpl 插件配置 >
" -----------------------------------------------------------------------------
" 增强源代码浏览,其功能就像Windows中的"Source Insight"
" :SrcExpl "打开浏览窗口
" :SrcExplClose "关闭浏览窗口
" :SrcExplToggle "打开/闭浏览窗口
" " -----------------------------------------------------------------------------
" " < supertab 插件配置 >
" " -----------------------------------------------------------------------------
" " 我主要用于配合 omnicppcomplete 插件,在按 Tab 键时自动补全效果更好更快
" " let g:supertabdefaultcompletiontype = "<c-x><c-u>"
" -----------------------------------------------------------------------------
" < std_c 插件配置 >
" -----------------------------------------------------------------------------
" 用于增强C语法高亮
" 启用 // 注视风格
let c_cpp_comments = 0
" -----------------------------------------------------------------------------
" < surround 插件配置 >
" -----------------------------------------------------------------------------
" 快速给单词/句子两边增加符号(包括html标签),缺点是不能用"."来重复命令
" 不过 repeat 插件可以解决这个问题,详细帮助见 :h surround.txt
" -----------------------------------------------------------------------------
" < Syntastic 插件配置 >
" -----------------------------------------------------------------------------
" 用于保存文件是查检语法
" -----------------------------------------------------------------------------
" < Tagbar 插件配置 >
" -----------------------------------------------------------------------------
" 相对 TagList 能更好的支持面向对象
" 常规模式下输入 tb 调用插件,如果有打开 TagList 窗口则先将其关闭
nmap tb :TlistClose<cr>:TagbarToggle<cr>
let g:tagbar_width=30 "设置窗口宽度
" let g:tagbar_left=1 "在左侧窗口中显示
" -----------------------------------------------------------------------------
" < TagList 插件配置 >
" -----------------------------------------------------------------------------
" 高效地浏览源码, 其功能就像vc中的workpace
" 那里面列出了当前文件中的所有宏,全局变量, 函数名等
" 常规模式下输入 tl 调用插件,如果有打开 Tagbar 窗口则先将其关闭
nmap tl :TagbarClose<cr>:Tlist<cr>
let Tlist_Show_One_File=1 "只显示当前文件的tags
" let Tlist_Enable_Fold_Column=0 "使taglist插件不显示左边的折叠行
let Tlist_Exit_OnlyWindow=1 "如果Taglist窗口是最后一个窗口则退出Vim
let Tlist_File_Fold_Auto_Close=1 "自动折叠
let Tlist_WinWidth=30 "设置窗口宽度
let Tlist_Use_Right_Window=1 "在右侧窗口中显示
" -----------------------------------------------------------------------------
" < txtbrowser 插件配置 >
" -----------------------------------------------------------------------------
" 用于文本文件生成标签与与语法高亮(调用TagList插件生成标签,如果可以)
au BufRead,BufNewFile *.txt setlocal ft=txt
" " -----------------------------------------------------------------------------
" " < WinManager 插件配置 >
" " -----------------------------------------------------------------------------
" " 管理各个窗口, 或者说整合各个窗口
" " 常规模式下输入 F3 调用插件
nmap <silent> mt :if IsWinManagerVisible() <BAR> WMToggle<CR> <BAR> else <BAR> WMToggle<CR>:q<CR> endif <CR>
" " 这里可以设置为多个窗口, 如'FileExplorer|TagList'
"let g:winManagerWindowLayout='FileExplorer'
let g:winManagerWindowLayout='NERDTree|TagList,Tarbar'
let g:persistentBehaviour=0 "只剩一个窗口时, 退出vim
let g:winManagerWidth=30 "设置窗口宽度
" -----------------------------------------------------------------------------
" < ZoomWin 插件配置 >
" -----------------------------------------------------------------------------
" 用于分割窗口的最大化与还原
" 快捷键 <c-w>o 在最大化与还原间切换
" =============================================================================
" << 以下为常用工具配置 >>
" =============================================================================
" -----------------------------------------------------------------------------
" < cscope 工具配置 >
" -----------------------------------------------------------------------------
" 用Cscope自己的话说 - "你可以把它当做是超过频的ctags"
if has("cscope")
"设定可以使用 quickfix 窗口来查看 cscope 结果
set cscopequickfix=s-,c-,d-,i-,t-,e-
"使支持用 Ctrl+] 和 Ctrl+t 快捷键在代码间跳转
set cscopetag
"如果你想反向搜索顺序设置为1
set csto=0
"在当前目录中添加任何数据库
if filereadable("cscope.out")
cs add cscope.out
"否则添加数据库环境中所指出的
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set cscopeverbose
"快捷键设置
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
endif
" -----------------------------------------------------------------------------
" < ctags 工具配置 >
" -----------------------------------------------------------------------------
" 对浏览代码非常的方便,可以在函数,变量之间跳转等
set tags=./tags; "向上级目录递归查找tags文件(好像只有在Windows下才有用)
" -----------------------------------------------------------------------------
" < gvimfullscreen 工具配置 > 请确保已安装了工具
" -----------------------------------------------------------------------------
" 用于 Windows Gvim 全屏窗口,可用 F11 切换
" 全屏后再隐藏菜单栏、工具栏、滚动条效果更好
if (g:iswindows && g:isGUI)
map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
endif
" -----------------------------------------------------------------------------
" < vimtweak 工具配置 > 请确保以已装了工具
" -----------------------------------------------------------------------------
" 这里只用于窗口透明与置顶
" 常规模式下 Shift + k 减小透明度,Shift + j 增加透明度,<Leader>t 窗口置顶与否切换
if (g:iswindows && g:isGUI)
let g:Current_Alpha = 255
let g:Top_Most = 0
func! Alpha_add()
let g:Current_Alpha = g:Current_Alpha + 10
if g:Current_Alpha > 255
let g:Current_Alpha = 255
endif
call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha)
endfunc
func! Alpha_sub()
let g:Current_Alpha = g:Current_Alpha - 10
if g:Current_Alpha < 155
let g:Current_Alpha = 155
endif
call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha)
endfunc
func! Top_window()
if g:Top_Most == 0
call libcallnr("vimtweak.dll","EnableTopMost",1)
let g:Top_Most = 1
else
call libcallnr("vimtweak.dll","EnableTopMost",0)
let g:Top_Most = 0
endif
endfunc
"快捷键设置
map <s-k> :call Alpha_add()<cr>
map <s-j> :call Alpha_sub()<cr>
map <leader>t :call Top_window()<cr>
endif
" =============================================================================
" << 以下为常用自动命令配置 >>
" =============================================================================
" 自动切换目录为当前编辑文件所在目录
"au BufRead,BufNewFile,BufEnter * cd %:p:h