-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathvimrc
598 lines (537 loc) · 22.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
<<<<<<< HEAD
" install Vundle bundles
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
=======
" Vundle {
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
set nocompatible " be iMproved, required
filetype off " required
" the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim' " 必须安装
Plugin 'SirVer/ultisnips' " Track the engine.
Plugin 'honza/vim-snippets' " Snippets are separated from the engine. Add this if you want them: Plugin 'unite.vim'
Plugin 'kien/rainbow_parentheses.vim' " 括号增强,彩色
Plugin 'trailing-whitespace' " 增加尾部空格的显示
Plugin 'commentary.vim' " 注释多行
Plugin 'surround.vim' " 补全括号或引号等cs,ds,yss
" Plugin 'bling/vim-bufferline' " 显示在airline里的buffer
" wm界面
Plugin 'The-NERD-tree'
Plugin 'minibufexpl.vim' " buffer插件
Plugin 'ctags.vim'
Plugin 'timestamp.vim' " 插入最后修改时间
Plugin 'plasticboy/vim-markdown' " Markdown格式高亮
Plugin 'flazz/vim-colorschemes' " 包含大部分配色
Plugin 'molokai' " 配色
Plugin 'vim-colors-solarized'
Plugin 'Tabular' " 注释等格式对齐插件
Plugin 'mru.vim' " 历史文件
Plugin 'ctrlp.vim' " 文件搜寻
Plugin 'Easymotion' " 文件快速定位
Plugin 'pydoc.vim' " python文档 :Pydoc int
Plugin 'Smooth-Scroll' " 平滑滚动
Plugin 'bling/vim-airline' " 状态栏
Plugin 'fugitive.vim' " git插件
Plugin 'Gist.vim' " gist
Plugin 'airblade/vim-gitgutter' " git diff
Plugin 'WebAPI.vim' " gist依赖插件
Plugin 'Tagbar' " 代替taglist
Plugin 'Valloric/YouCompleteMe' " 补全插件
Plugin 'SuperTab'
" Plugin 'Townk/vim-autoclose' " 括号补全
" Plugin 'pyflakes.vim' " python语法检测
" Plugin 'mattn/emmet-vim' " Zencoding
" Plugin 'Pydiction' " python自动补全
" Plugin 'bufexplorer.zip' " 打开历史文件 :BufExplorer
" Plugin 'OmniCppComplete' " c/c++补全
" Plugin 'Syntastic' " 语法检查
call vundle#end() " required
filetype plugin indent on " required
" }
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
" General {
set autowrite " 自动保存
set shell=bash\ -i
set tags+=./tags;
set t_Co=256 " airline 颜色显示
set ambiwidth=double
set mouse=a " 鼠标支持
filetype plugin on " 允许插件
set helplang=cn " 中文文档
set nobackup " 从不备份
set noswapfile " 关闭交换文件
<<<<<<< HEAD
set wildignore=*.swp,*.bak,*.pyc,*.class,.svn
set undodir=~/.undodir
=======
set undodir=~/.undodir
" set whichwrap+=<,>,h,l " 退格和方向可以换行
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
set mouse=n " 所有模式使用鼠标
set matchtime=1 " 匹配括号高亮的时间(单位是十分之一秒)
let &termencoding=&encoding " 中文设置
set fileencodings=utf-8,gbk " 中文设置
<<<<<<< HEAD
set foldmethod=indent " 代码折叠 indent
set foldlevel=99
=======
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
" 设置 退出vim后,内容显示在终端屏幕, 可以用于查看和复制,好处:误删什么的,
" 如果以前屏幕打开,可以找回
set t_ti= t_te=
" tab切换页面
set hidden "in order to switch between buffers with unsaved change
map <tab> :bn<cr>
map <S-tab> :bp<cr>
" 插入模式下用绝对行号, 普通模式下用相对
autocmd InsertEnter * :set norelativenumber number
autocmd InsertLeave * :set relativenumber
<<<<<<< HEAD
" 打开文件时自动回到上次编辑的地方
if has("autocmd")
autocmd BufRead *.txt set tw=78
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
endif
"断行
=======
" 断行
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
" set columns=80
" set tw=80
" set fo+=Mm
" set fillchars=vert:\ ,stl:\ ,stlnc:\ " 在被分割的窗口间显示空白,便于阅读
<<<<<<< HEAD
"map <C-A> ggVG"+y
" autocmd! bufwritepost .vimrc source % " vimrc文件修改之后自动加载。 linux。
=======
" map <C-A> ggVG"+y
autocmd! bufwritepost .vimrc source % " vimrc文件修改之后自动加载。 linux。
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
set modifiable
" 打开文件时自动回到上次编辑的地方
if has("autocmd")
autocmd BufRead *.txt set tw=78
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
endif
" }
" vim-UI {
syntax enable " 语法高亮
set background=dark
let g:solarized_termcolors=256
" colorscheme Tomorrow-Night-Eighties " molokai zenburn Tomorrow
colorscheme solarized " molokai zenburn Tomorrow
se guifont=Consola:h12 " 设置默认字体
highlight clear SignColumn
highlight clear LineNr
<<<<<<< HEAD
" colorsheme solarized {
" let g:solarized_termtrans=1
" let g:solarized_contrast="low"
" let g:solarized_visibility="low"
=======
" solarized {
" let g:solarized_termcolors=256
let g:solarized_termtrans=0
let g:solarized_contrast="high"
let g:solarized_visibility="high"
call togglebg#map("<F6>") " 切换背景
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
" }
colorscheme solarized " molokai zenburn Tomorrow
" molokai {
"let g:molokai_original = 1
"let g:rehash256 = 1
" }
<<<<<<< HEAD
=======
" fold {
set foldenable " 自动折叠
set foldmethod=marker " 折叠方式 indent
set foldmarker={,}
" set foldcolumn=2 " 左侧折叠标记 + -
" }
" search {
set incsearch " 跟踪搜索
set hlsearch " 高亮搜索
set ignorecase " 搜索忽略大小写
" }
" 超过80个字符会高亮
" highlight OverLength ctermbg=darkred ctermfg=white guibg=#592929
" match OverLength /\%81v.\+/
" 显示80个字符竖线
set cc=80
"设置标记一列的背景颜色和数字一行颜色一致
hi! link SignColumn LineNr
hi! link ShowMarksHLl DiffAdd
hi! link ShowMarksHLu DiffChange
highlight Normal ctermbg=NONE
highlight nonText ctermbg=NONE
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
set cursorline " 突出显示当前行
set cursorcolumn " 突出显示当前列
set relativenumber " 设置相对行号
set nu " 显示行号
set ruler " 显示ruler
<<<<<<< HEAD
set linespace=0 " 行之间没有多余空格
=======
set linespace=0 " 行之间没有多余空格,只在GUI中
set nu " 显示行号
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
set showmatch " 高亮显示匹配的括号
set wildmenu " 输入vim命令时补全菜单
" set wildmode=list:longest,full " 输入Tab时,先列出符合的,再列出最长匹配,最后是全部
set scrolljump=5 " 光标离开屏幕滑动距离
set scrolloff=3 " 滑动时离上下行最短距离
set ai " 自动缩进
set si " 只能缩进
set cindent " c/c++风格
set backspace=eol,start,indent
set cc=80 " 80列高亮
" set list " 把制表符显示为^I,用$标示行尾
" }
" Formatting {
set nowrap " 控制长行是否折到下一行显示
set autoindent " 把当前行的对起格式应用到下一行
set shiftwidth=4 " 缩进用4个空格表示
set expandtab " 用空格代替tab
set tabstop=4 " 一个tab相当于4个空格
set smarttab
set softtabstop=4 " backspace可以删除缩进
set nojoinspaces "用J命令合并两行时会用一个空格来分隔
" }
" Key (re)Mappings {
let mapleader = "f"
" jk is escape
inoremap jk <esc>
" highlight last inserted text
nnoremap gV `[v`]
" move to beginning/end of line
nnoremap B ^
nnoremap E $
" $/^ doesn't do anything
nnoremap $ <nop>
nnoremap ^ <nop>
" 编辑模式下写括号时的快捷键
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
map <S-p> :!open -a /Applications/Google\ Chrome.app/ "%:p" <CR>
" <F2> 去空行 {
nnoremap <F2> :g/^\s*$/d<CR>
" }
" <F3> 删除多余空格 {
map <F3> :%s/\s\+$//<CR>
" }
" <F4> 相对和绝对行号切换 {
nnoremap <F4> :call NumberToggle()<cr>
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber number
else
set relativenumber
endif
endfunc
" }
" <F5> 编译运行 {
map <F5> :call CompileRun()<CR>
func! CompileRun()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!time ./%<"
exec "!rm ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
exec "!rm ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<"
exec "!rm ./%<.class"
elseif &filetype == 'sh'
exec "!time bash %"
elseif &filetype == 'python'
exec "!time python %"
elseif &filetype == 'html'
exec "!chrome % &"
elseif &filetype == 'go'
exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'md' "MarkDown 解决方案为VIM + Chrome浏览器的MarkDown Preview Plus插件,保存后实时预览
exec ":!open -a /Applications/Google\ Chrome.app/ % &"
elseif &filetype == 'javascript'
exec "!time node %"
elseif &filetype == 'coffee'
exec "!time coffee %"
elseif &filetype == 'ruby'
exec "!time ruby %"
endif
endfunc
" }
" <F6> 开启/关闭行号显示 {
function! HideNumber()
if(&relativenumber == &number)
set relativenumber! number!
elseif(&number)
set number!
else
set relativenumber!
endif
set number?
endfunc
nnoremap <F6> :call HideNumber()<CR>
" }
<<<<<<< HEAD
" <F7> 语法开关 {
nnoremap <F7> :exec exists('syntax_on') ? 'syn off' : 'syn on'<CR>
=======
" <F9> 粘贴不带缩进{
set pastetoggle=<F9>
" }
" }
" Plugins {
" ctrlp {
let g:ctrlp_map = ',,'
let g:ctrlp_open_multiple_files = 'v'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " 列表中忽略这些文件
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git)$',
\ 'file': '\v\.(log|jpg|png|jpeg)$',
\ }
" }
" MRU {
map ,h :MRU<cr>
let MRU_Max_Entries=50 " 记录条数
" }
" ultisnips {
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<tab>"
" let g:UltiSnipsJumpForwardTrigger="<c-b>"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
" let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" }
" SuperTab {
" }
" commentary {
"支持不同文件类型
"gcc:注释一行
"gc:可以注释多行,配合<C-v>
autocmd FileType apache set commentstring=#\ %s
" }
" ranbow_parenthese.vim {
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkred', 'DarkOrchid3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
"always on:
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" }
" minibuffexploer {
"常用操作
" :e <filename> 打开文件
" :ls 当前打开的buf
" :bn 下一个buf
" :bp 前一个buf
" :b<n> n是数字,第n个buf
" :b<tab> 自动补齐
" :bd 删除
let g:miniBufExplMapWindowNavVim = 1 "<C-h,j,k,l>切换到上下左右的窗口中去
let g:miniBufExplMapWindowNavArrows = 1 "<C-箭头>箭头切换
let g:miniBufExplMapCTabSwitchBufs = 1 "<C-Tab>切换窗口(有冲突)
" let g:miniBufExplModSelTarget = 1
let g:miniBufExplMoreThanOne=0
" }
" NERDTree {
let g:NERDTree_title="[NERDTree]"
" let g:winManagerWindowLayout="NERDTree|TagList"
" function! NERDTree_Start()
" exec 'NERDTree'
" endfunction
" function! NERDTree_IsValid()
" return 1
" endfunction
" nmap wm :WMToggle<CR>
" }
" Easymotion {
let g:EasyMotion_leader_key = 'f'
" }
" youcompleteme {
" 屏蔽一些文件
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'qf' : 1,
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'unite' : 1,
\ 'text' : 1,
\ 'vimwiki' : 1,
\ 'gitcommit' : 1,
\}
" let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
" let g:syntastic_always_populate_loc_list = 1
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py"
" 超级有用文件跳转
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" }
" multiple-cursors-master {
" Ctrl-n选择下一个相同的单词
" Ctrl-p往回选一个
" Ctrl-x则跳过下一个相同单词
" }
" vim-markdown {
let g:vim_markdown_initial_foldlevel= 1
let g:vim_markdown_folding_disabled=1 "去掉折叠
let g:markdown_no_default_key_mappings=1 "默认键失效
" }
" LASTCHANGED {
let timestamp_regexp = '\v\C%(<Last %([cC]hanged?|[Mm]odified):\s+)@<=.*$'
set modelines=20
let g:timestamp_rep = strftime("%c")
" }
" vim-expand-region {
map <space> <Plug>(expand_region_expand)
" 空格键映射到+
" map J <Plug>(expand_region_shrink)
" }
" airline {
" let g:airline#extensions#tabline#enabled = 1
let g:airline_theme="powerlineish" "powerlineish
let g:airline_powerline_fonts=1
set laststatus=2
" let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tabline#left_sep = ' '
" let g:airline#extensions#tabline#left_alt_sep = '|'
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
" }
" <F9> 粘贴不带缩进{
set pastetoggle=<F9>
" }
" }
" Settings {
" 关闭最后窗口同时关闭nerdtree {
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function! s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
q
elseif winnr("$") == 2
if bufwinnr("__Tag_List__") != -1
q
endif
endif
endif
endif
endfunction
" }
<<<<<<< HEAD
autocmd! bufwritepost .vimrc source % " vimrc文件修改之后自动加载。 linux。
=======
" 新建.c,.h,.sh,.java文件,自动插入文件头 {
autocmd BufNewFile *.md exec ":call Setmd()"
func Setmd()
call setline(1,"date: ".strftime("%Y-%m-%d %T"))
call append(line("."),"tags: ")
call append(line(".")+1,"---")
call append(line(".")+2,"")
endfunc
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.py,*.html,*.php,*java exec ":call SetTitle()"
""定义函数SetTitle,自动插入文件头
func SetTitle()
if &filetype=='python'
call setline(1, "#-*- encoding: UTF-8 -*-")
call append(line("."), "#---------------------------------import------------------------------------")
call append(line(".")+1, "#---------------------------------------------------------------------------")
call append(line(".")+2, "############################################################################")
endif
if &filetype=='sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: limbo")
call append(line(".")+2, "\# mail: [email protected]")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\# Last changed: TIMESTAMP")
call append(line(".")+5, "\#########################################################################")
call append(line(".")+6, "\#!/bin/bash".expand("%"))
call append(line(".")+7, "")
endif
if &filetype=='html' || &filetype=='php'
call setline(1, "<!--*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: limbo")
call append(line(".")+2, " > Mail: [email protected]")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " > Last changed: TIMESTAMP")
call append(line(".")+5, " ************************************************************************-->")
call append(line(".")+6, "")
endif
if &filetype=='cpp'
call append(line(".")+6, "#include<iostream>")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
endif
if &filetype=='c'
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author: limbo")
call append(line(".")+2, " > Mail: [email protected]")
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " > Last changed: 2014年12月24日 星期三 11时12分46秒
call append(line(".")+5, " ************************************************************************/")
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
endif
if &filetype=='php' || &filetype=='html'
call setline(9,['<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">','<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">','<head>',' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',' <title></title>','</head>','<body>','</body>','</html>'])
endif
if &filetype=='java'
call setline(9,['public class '.strpart(expand("%"),0,strlen(expand("%"))-5),'{','}'])
endif
endfunc
autocmd BufNewFile * normal G "新建文件后,自动定位到文件末尾
" }
>>>>>>> ab8e0c152f321431137c20f35edef5bef963b828
" }