-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
426 lines (400 loc) · 10.7 KB
/
.vimrc
File metadata and controls
426 lines (400 loc) · 10.7 KB
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
"******************************************************
"bundle配置
"******************************************************
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Bundle 'gmarik/vundle'
Bundle 'majutsushi/tagbar'
"nmap <Leader> tb :TagbarToggle<CR>
map <F3> :Tagbar<CR>
Bundle 'vim-scripts/a.vim'
Bundle 'scrooloose/nerdtree'
map <F2> :NERDTreeToggle<CR>
Bundle 'fholgado/minibufexpl.vim'
let g:miniBufExplMapWindowNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplMapCTabSwitchBufs=1
let g:miniBufExplModSelTarget=1
let g:miniBufExplMoreThanOne=0
map <F11> :MBEbp<CR>
map <F12> :MBEbn<CR>
Bundle 'bling/vim-airline'
set laststatus=2
let g:ariline#extensions#tabline#enabled=1
let g:ariline#extensions#tabline#left_sep=' '
let g:ariline#extensions#tabline#left_alt_sep='|'
Bundle 'vim-scripts/winmanager'
"let g:NERDTree_title="[NERDTree]"
"let g:winManagerWindowLayout="NERDTree|BufExplorer"
"function! NERDTree_start()
" exec 'NERDTree'
"endfunction
"function! NERDTree_IsValid()
" return 1
"endfunction
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<CR>
Bundle 'taglist.vim'
"关闭单个文件的taglist按d
"寻找定义的tag按o
let Tlist_Ctags_Cmd='ctags'
let Tlist_Show_One_Files=1
let Tlist_WinWidt=28
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Left_Windo=1
Bundle 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
"添加c++11的支持
let g:syntastic_cpp_comiler='g++'
let g:syntastic_cpp_comiler_options='-std=c++11 -stdlib=libc++'
Bundle 'scrooloose/nerdcommenter'
let mapleader=","
",cc注释当前行
",c<space>取消掉注释
",cm注释块
Bundle 'scrooloose/syntastic'
"let g:syntastic_stl_format='[%E{Err: %fe #%e}%B{, }%w{Warn: %fw #%w}]'
"set statusline+=%#warningmsg#
"set statusline+=%{StntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list=1
""自动打开location list
"let g:syntastic_auto_loc_list=1
"let g:syntastic_auto_loc_height=5
"let g:syntastic_check_on_open=1
"let g:syntastic_check_on_wp=0
"let g:syntastic_cpp_comiler='g++'
"let g:syntastic_cpp_comiler_options='-std=c++11 -Wall'
"let g:syntastic_cpp_config_file='.syntastic_cpp_config'
Bundle 'jiangmiao/auto-pairs'
"括号自动补全
Bundle 'altercation/vim-colors-solarized'
Bundle 'octol/vim-cpp-enhanced-highlight'
"Bundle 'godlygeek/tabular'
"Bundle 'plasticboy/vim-markdown'
"let g:vim_markdown_folding_disable=1
"set foldenable
Bundle 'vim-scripts/DoxygenToolKit.vim'
":Dox自动生成函数说明
":DoxAuthor自动生成文件说明
":DoxLic生成许可之类的东西
let g:DoxygenToolkit_briefTag_pre="@Synopsis "
let g:DoxygenToolkit_paramTag_pre="@Param "
"let g:DoxygenToolkit_returnTag="@Return "
let g:DoxygenToolkit_authorName="Max577769190"
let g:DoxygenToolkit_briefTag_funcName="yes"
call vundle#end()
filetype plugin indent on
"******************************************************
"bundle配置end
"******************************************************
if(has("win32") || has("win95") || has("win64") || has("win16"))
let g:iswindows=1
else
let g:iswindows=0
endif
set nocompatible "不要VIM模仿VI模式
if has("autocmd")
filetype plugin indent on "根据文件进行缩进
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
augroup END
else
"智能缩进
set autoindent "always set autoindenting on
endif " has("autocmd")
set tabstop=4 "让一个tab等于4个空格
set vb t_vb=
set hlsearch "高亮显示搜索结果
set incsearch "实时匹配
set backspace=indent,eol,start whichwrap+=<,>,[,] "退格键使用
"检测文件类型 插入文件类型插件 插入特定的文件类型插件
filetype on
filetype plugin on
filetype indent on
filetype plugin indent on
"全能补全 不会用
"set completeopt=longest,menu
set autochdir "自动设置当前编辑的目录为工作目录
syntax enable
syntax on "语法高亮
set nu
set autoindent "自动对齐
set smartindent "智能选择对其方式
"设置tab键为4个空格 行之间交错是使用4个空格
set tabstop=4
set shiftwidth=4
"设置括号匹配模式
set showmatch
"显示光标位置的状态行
set ruler
set novisualbell
"没有多余的文件
set nobackup
set noswapfile
"用256色
"t t_Co=256
"UTF-8编码
set encoding=utf-8
"找到c.vim cpp.vim
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>s*("me=e-2
"窗口切换
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
"避免出现多余的空白字符
"au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
"显示行编辑行总在中间
set so=20
"禁止光标闪烁,只对gvim生效
set gcr=a:block-blinkon0
set cursorline
set cursorcolumn
"""""""""""""""""""""""""""""
"关于gvim的一些配置
"“‘”“”“”“”“”“”“”“”“”“”’“”“”“”
if has("gui_running")
let g:isGUI = 1
else
let g:isGUI = 0
endif
if (g:isGUI)
"去掉边框
set go =
"设置字体以及行间距
set guifont=DejaVu\ Sans\ Mono\ 11
set guifontwide=FZXingKai\-S04\ 11
"高亮显示当前行与列
set cursorline
set cursorcolumn
"配色方案设置
colorscheme solarized
"colorscheme desert
"colorscheme molokai
set background=dark
"全屏
function! ToggleFullScreen()
call system("wmctrl -r :ACTIVE: -b toggle,fullscreen")
endfunction
map <silent><F11> :call ToggleFullScreen()<CR>
endif
"""""""""""""""""""""""""""""""""""""""""""""'""""""'"""""""""""""
""编译c++文件
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
func! CompileGpp()
exec "w"
let compilecmd="!g++ "
let compileflag="-std=c++11"
exec compilecmd." % ".compileflag
endfunc
func! CompileGcc()
exec "w"
let compilecmd="!gcc "
exec compilecmd." % "
endfunc
func! CompilePython()
exec "w"
let compilecmd="!python "
exec compilecmd." % "
endfunc
func! CompileCode()
exec "w"
if &filetype == "cpp"
exec "call CompileGpp()"
elseif &filetype == "c"
exec "call CompileGcc()"
elseif &filetype == "python"
exec "call CompilePython()"
endif
endfunc
map <F5> :call CompileCode()<CR>
func! RunCode()
exec "w"
exec "! ./a.out"
endfunc
map <F6> :call RunCode()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''""
" =========== NERDTree 和 Tagbar 共用一个窗口 ========
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! ToggleNERDTreeAndTagbar()
let w:jumpbacktohere = 1
" Detect which plugins are open
if exists('t:NERDTreeBufName')
let nerdtree_open = bufwinnr(t:NERDTreeBufName) != -1
else
let nerdtree_open = 0
endif
let tagbar_open = bufwinnr('__Tagbar__') != -1
" Perform the appropriate action
if nerdtree_open && tagbar_open
NERDTreeClose
TagbarClose
elseif nerdtree_open
TagbarOpen
wincmd J
wincmd k
wincmd L
elseif tagbar_open
NERDTree
wincmd J
wincmd k
wincmd L
else
NERDTree
TagbarOpen
wincmd J
wincmd k
wincmd L
endif
" 改变窗口宽度
vertical resize +50
" Jump back to the original window
" for window in range(1, winnr('$'))
" execute window . 'wincmd w'
" if exists('w:jumpbacktohere')
" unlet w:jumpbacktohere
" break
" endif
"endfor
endfunction
" nnoremap <leader>\ :call ToggleNERDTreeAndTagbar()<CR>
" 打开 vim 时自动打开 NERDTree 和 Tagbar
"autocmd vimenter * call ToggleNERDTreeAndTagbar()
" ===================================================
" nomarl config
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
set nu
if(has("win32") || has("win95") || has("win64") || has("win16"))
let g:iswindows=1
else
let g:iswindows=0
endif
set nocompatible "不要VIM模仿VI模式
if has("autocmd")
filetype plugin indent on "根据文件进行缩进
augroup vimrcEx
au!
autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
augroup END
else
"智能缩进
set autoindent "always set autoindenting on
endif " has("autocmd")
set tabstop=4 "让一个tab等于4个空格
set vb t_vb=
set hlsearch "高亮显示搜索结果
set incsearch "实时匹配
set backspace=indent,eol,start whichwrap+=<,>,[,] "退格键使用
"检测文件类型 插入文件类型插件 插入特定的文件类型插件
filetype on
filetype plugin on
filetype indent on
filetype plugin indent on
"全能补全 不会用
"set completeopt=longest,menu
set autochdir "自动设置当前编辑的目录为工作目录
syntax enable
syntax on "语法高亮
set nu
set autoindent "自动对齐
set smartindent "智能选择对其方式
"设置tab键为4个空格 行之间交错是使用4个空格
set tabstop=4
set shiftwidth=4
"设置括号匹配模式
set showmatch
"显示光标位置的状态行
set ruler
set novisualbell
"没有多余的文件
set nobackup
set noundofile
set noswapfile
"用256色
"t t_Co=256
"UTF-8编码
set encoding=utf-8
"找到c.vim cpp.vim
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>s*("me=e-2
"窗口切换
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
"避免出现多余的空白字符
"au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
"显示行编辑行总在中间
set so=20
"禁止光标闪烁,只对gvim生效
set gcr=a:block-blinkon0
set cursorline
set cursorcolumn
"""""""""""""""""""""""""""""
"关于gvim的一些配置
"“‘”“”“”“”“”“”“”“”“”“”’“”“”“”
if has("gui_running")
let g:isGUI = 1
else
let g:isGUI = 0
endif
if (g:isGUI)
"去掉边框
set go =
"设置字体以及行间距
"set guifont=DejaVu\ Sans\ Mono\ 11
"set guifontwide=FZXingKai\-S04\ 11
set guifont=Courier\ New:h11
"高亮显示当前行与列
set cursorline
set cursorcolumn
"配色方案设置
"colorscheme solarized
"colorscheme desert
colorscheme molokai
"set background=dark
endif