This repository was archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
executable file
·940 lines (791 loc) · 28.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
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
" _ __ _ __ ___
" | |/ /___ _ __ | | ___ _ __ \ \ / (_)_ __ ___
" | ' // _ \ '_ \| |/ _ \ '__| _____ \ \ / /| | '_ ` _ \
" | . \ __/ |_) | | __/ | |_____| \ V / | | | | | | |
" |_|\_\___| .__/|_|\___|_| \_/ |_|_| |_| |_|
" |_|
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
python << EOF
import time
import vim
def SetBreakpoint():
nLine = int( vim.eval( 'line(".")'))
strLine = vim.current.line
i = 0
strWhite = ""
while strLine[i] == ' ' or strLine[i] == "\t":
i += 1
strWhite += strLine[i]
vim.current.buffer.append(
# "%(space)spdb.set_trace() %(mark)s Breakpoint %(mark)s" %
"%(space)sipdb.set_trace() %(mark)s Breakpoint %(mark)s" %
{'space':strWhite, 'mark': '#' * 30}, nLine - 1)
for strLine in vim.current.buffer:
# if strLine == "import pdb":
if strLine == "import ipdb":
break
else:
# vim.current.buffer.append( 'import pdb', 0)
vim.current.buffer.append( 'import ipdb', 0)
vim.command( 'normal j1')
break
vim.command( 'map <C-d> :py SetBreakpoint()<cr>')
def RemoveBreakpoints():
nCurrentLine = int( vim.eval( 'line(".")'))
nLines = []
nLine = 1
for strLine in vim.current.buffer:
if strLine == 'import pdb' or strLine.lstrip()[:15] == 'pdb.set_trace()':
nLines.append( nLine)
nLine += 1
nLines.reverse()
for nLine in nLines:
vim.command( 'normal %dG' % nLine)
vim.command( 'normal dd')
if nLine < nCurrentLine:
nCurrentLine -= 1
vim.command( 'normal %dG' % nCurrentLine)
vim.command( 'map <C-F8> :py RemoveBreakpoints()<cr>')
# vim.command( 'map <C-D> :!python %<cr>')
EOF
" let g:vebugger_leader = ','
syntax on
" vim自身命名行模式智能补全
set wildmenu
" 让vim可以使用系统的剪切板
set clipboard=unnamed
" 自动设当前编辑文件所在目录为当前工作目录
" set autochdir
let mapleader=";"
" inoremap ( ()<ESC>i
" inoremap [ []<ESC>i
" inoremap { {}<ESC>i
" inoremap < <><ESC>i
" -------- -------- -------- -------- -------- --------
" python with virtualenv support
" -------- -------- -------- -------- -------- --------
py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
'''
add this
'''
sys.path.insert(0,project_base_dir)
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
EOF
" -------- -------- -------- -------- -------- --------
" auto add head info
" -------- -------- -------- -------- -------- --------
function HeaderPython()
call setline(1, "# !/usr/bin/env python")
call append(1, "# _*_ coding:utf-8")
normal G
normal o
endf
autocmd bufnewfile *.py call HeaderPython()
" -------- -------- -------- -------- -------- --------
"窗口分割
"-------- -------- -------- -------- -------- --------
set splitbelow
set splitright
" -------- -------- -------- -------- -------- --------
"翻译
"-------- -------- -------- -------- -------- --------
nmap <silent> <Leader>fy <Plug>DictSearch
" -- 普通模式下,<Leader>d 即可翻译光标下的文本,并在命令行回显
vmap <silent> <Leader>fy <Plug>DictVSearch
" -- 可视化模式下,<Leader>d 即可翻译选中的文本,并在命令行回显
" nmap <silent> <Plug>DictWSearch
" -- 普通模式下,<Leader>w 即可翻译光标下的文本,并且在Dict新窗口显示
" vmap <silent> <Plug>DictWVSearch
" -- 可视化模式下,<Leader>w 即可翻译选中的文本,并且在Dict新窗口显示
" -- :Dict word 在命令行回显
" -- :DictW word 在一个分割窗口中显示
"-------- -------- -------- -------- -------- --------
"fugitive
"-------- -------- -------- -------- -------- - -------
"Gstatus git status
"Gcommit git commit
"Gdiff git diff
"Glog git log
"Gread git checkout file_name
"Gwrite git add file_name
"Gmove git mv
"Gremove git rm
"-------- -------- -------- -------- -------- --------
"autospace
"设置= + - * 前后自动插入空格
"-------- -------- -------- -------- -------- --------
au FileType python inoremap <buffer>, ,<space>
let g:equ=1
if exists("g:equ")
:inoremap << <c-r>=EqualSign('<<')<CR>
" :inoremap >> <c-r>=EqualSign('>>')<CR>
" :inoremap + <c-r>=EqualSign('+')<CR>
" :inoremap - <c-r>=EqualSign('-')<CR>
" " :inoremap * <c-r>=EqualSign('*')<CR>
:inoremap = <c-r>=EqualSign('=')<CR>
" :inoremap += <c-r>=EqualSign('+=')<CR>
endif
function! EqualSign(char)
if a:char =~ '=' && getline('.') =~ ".*("
return a:char
endif
let ex1 = getline('.')[col('.') - 3]
let ex2 = getline('.')[col('.') - 2]
if ex1 =~ "[-=+><>\/\*]"
if ex2 !~ "\s"
return "\<ESC>i".a:char."\<SPACE>"
else
return "\<ESC>xa".a:char."\<SPACE>"
endif
else
if ex2 !~ "\s"
return "\<SPACE>".a:char."\<SPACE>\<ESC>a"
else
return a:char."\<SPACE>\<ESC>a"
endif
endif
endf
"-------- -------- -------- -------- -------- --------
"easy-motion
"-------- -------- -------- -------- -------- --------
"
let g:EasyMotion_leader_key = '<Leader>'
"-------- -------- -------- -------- -------- --------
"ALE
"-------- -------- -------- -------- -------- --------
"-------- -------- -------- -------- -------- --------
"Syntastic
"-------- -------- -------- -------- -------- --------
" let g:syntastic_error_symbol='✗'
" let g:syntastic_error_symbol='.'
" let g:syntastic_warning_symbol='⚠'
" 第一时间检查发现任何错误
" let g:syntastic_aggregate_errors=1
" 自动调用:syntasticsetloclist, 将错误覆盖"qiuckfix"
" let g:syntastic_always_populate_loc_list=1
" 打开文件或保存时显示错误提示
" let g:syntastic_check_on_open=1
" let g:syntastic_check_on_w=1
"
" 是否自动弹出关闭错误窗口
" let g:syntastic_auto_loc_list=1
" 自动跳转到地一个错误或警告处
" let g:syntastic_auto_jump = 1
" 鼠标悬停显示错误
" let g:syntastic_enable_balloons=1
" let g:syntastic_loc_list_height=5
" vim-quick python代码检查插件
" let g:pyflakes_use_quickfix=1
". let g:syntastic_python_checkers= ['pyflakes']
" let g:syntastic_cpp_include_dirs= ['/usr/include/']
" let g:syntastic_cpp_check_header = 1
" let g:syntastic_cpp_checkers= ['gcc']
" let g:syntastic_cpp_compiler= 'gcc'
" let g:syntastic_cpp_compiler_options= '-std=c++11'
"-------- -------- -------- -------- -------- --------
"-------- -------- -------- -------- -------- --------
nmap <Leader>e :lopen<cr>
nmap <Leader>c :lclose<cr>
nmap <Leader>n :lnext<cr>
nmap <Leader>p :lpre<cr>
"=========================折叠================================
"开启折叠,并设置空格开关
set foldenable
set foldmethod=indent
" set foldmethod=syntax
"设置折叠区宽度
set foldcolumn=0
"设置折叠层数
setlocal foldlevel=1
"设置自动关闭折叠
"set foldclose=all
"设置空格开关折叠
nnoremap <space> @=((foldclosed(line('.'))<0)?'zc':'zo')<CR>
"设置刚开始时不自动折叠
set foldlevelstart=99
"搜索和undo时不展开设置好的折叠
set foldopen-=search
set foldopen-=undo
"设置竖直对齐线
" :set list lcs=tab:\¦\
" to deal with it's slow when I swith insert to normal
set ttimeoutlen=0
"-------- -------- -------- -------- -------- --------
"title
"-------- -------- -------- -------- -------- --------
function AddTitle()
call append(0,"/***********************************************************")
call append(1,"* Author : M_Kepler")
call append(2,"* EMail : m_kepler@foxmail.com")
call append(3,"* Last modified: ".strftime("%Y-%m-%d %H:%M:%S"))
call append(4,"* Filename : ".expand("%:t"))
call append(5,"* Description :")
call append(6,"**********************************************************/")
call append(7,"")
echohl WarningMsg | echo "Successful in adding the copyright."|echohl None
endfunction
function UpdateTitle()
normal m'
execute '/* Last modified:/s@:.*$@\=strftime(": %Y-%m-%d %H:%M:%S")@'
normal ''
normal mk
execute '/* Filename :/s@:.*$@\=": ".expand("%:t")@'
execute "noh"
normal 'k
echohl WarningMsg | echo "Successful in updating the copyright." | echohl None
endfunction
function TitleDet()
let n=1
while n < 10
let line = getline(n)
if line =~'^\*\s*\S*Last\smodified:\S*.*$'
call UpdateTitle()
return
endif
let n = n + 1
endwhile
call AddTitle()
endfunction
nmap <leader>3 :call TitleDet() <CR>
source ~/.vim/bundles.vim
"set windows size
" set lines =25 columns=80
winpos 200 100
" 禁止生成临时文件
set nobackup
" 在处理未保存或只读文件的时候,弹出确认
set confirm " prompt when existing from an unsaved file
" encoding dectection
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set encoding=utf8
"-------- -------- -------- -------- -------- --------
" ColorScheme "按<Leader>yy键依次修改颜色主题
"-------- -------- -------- -------- -------- --------
" set background=light
" set background=dark
" colorscheme solarized
" colorscheme tir_black
colorscheme space-vim-dark
" colorscheme default
"
" colorscheme molokai
" colorscheme atom-dark-256
" colorscheme dracula
" colorscheme railscasts
" colorscheme desert
let python_hithlight_all=1
let g:csnum = 0
"定义全局变量用于切换颜色主题"
map <Leader>yy :call ChangeColorScheme()<CR>
function! ChangeColorScheme()
if g:csnum == 0
:colorscheme torte
:let g:csnum = 1
elseif g:csnum == 1
:colorscheme murphy
:let g:csnum = 2
elseif g:csnum == 2
:colorscheme desert
:let g:csnum = 3
elseif g:csnum == 3
:colorscheme murphy
:let g:csnum = 4
elseif g:csnum == 4
:colorscheme delek
:let g:csnum = 5
elseif g:csnum == 5
:colorscheme elflord
:let g:csnum = 6
elseif g:csnum == 6
:colorscheme evening
:let g:csnum = 7
elseif g:csnum == 7
:colorscheme koehler
:let g:csnum = 8
" elseif g:csnm == 9
" :colorscheme dracula
else
:colorscheme default
:let g:csnum = 0
endif
endfunction
"-------- -------- -------- -------- -------- --------
" Air-line
"-------- -------- -------- -------- -------- --------
let g:airline_powerline_fonts=1
" let g:airline_theme='light'
let g:airline_theme='luna'
" let g:airline_theme='behelit'
" 显示上面的buffer tab
let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tabline#left_sep = ' '
" let g:airline#extensions#tabline#left_alt_sep = '|'
"-------- -------- -------- -------- -------- --------
" buffer
"-------- -------- -------- -------- -------- --------
nnoremap <Leader>bn :bn<cr>
nnoremap <Leader>bp :bp<cr>
" nnoremap <Leader>bc :bd<cr>
nnoremap <Leader>x :bd<cr>
" nnoremap <Leader>tn :tabnew<cr>
nnoremap <Leader>1 :b1<cr>
nnoremap <Leader>2 :b2<cr>
nnoremap <Leader>3 :b3<cr>
nnoremap <Leader>4 :b4<cr>
"-------- -------- -------- -------- -------- --------
" quickfix
"-------- -------- -------- -------- -------- --------
" highlight current line
au WinLeave * set nocursorline nocursorcolumn
au WinEnter * set cursorline cursorcolumn
set cursorline cursorcolumn
" search
set magic
set incsearch
set ignorecase
set smartcase
" editor settings
set history=1000
set nocompatible
set backspace=indent,eol,start " More powerful backspacing
set t_Co=256 " Explicitly tell vim that the terminal has 256 colors "
set mouse=a " use mouse in all modes
set report=0 " always report number of lines changed "
set nowrap " dont wrap lines
set scrolloff=5 " 5 lines above/below cursor when scrolling
set number " show line numbers
set relativenumber
set showmatch " show matching bracket (briefly jump)
set showcmd " show typed command in status bar
set title " show file in titlebar
set laststatus=2 " use 2 lines for the status bar
set matchtime=1 " show matching bracket for 0.2 seconds
set matchpairs+=<:> " specially for html
" set relativenumber
" Default Indentation
" enable filetype dectection and ft specific plugin/indent
filetype plugin indent on
filetype plugin on
filetype indent on
set autoindent
set cindent
set smartindent " indent when
set tabstop=4 " tab width
set softtabstop=4 " backspace
set shiftwidth=4 " indent width
"set textwidth=79
"set smarttab
set expandtab " expand tab to space
"-------- -------- -------- -------- -------- --------
"vim-markdown
"-------- -------- -------- -------- -------- --------
" set chrome path
let g:mkdp_path_to_chrome = "google-chrome"
" 设置不自动打开chrome预览
let g:mkdp_auto_start = 0
" set to 1: 检查预览窗口是否打开,否则自动打开
let g:mkdp_auto_open = 0
" 在切换buffer的时候自动关闭预览窗口
let g:mkdp_auto_close = 0
" real-time preview
let g:mkdp_refresh_slow = 0
autocmd FileType php setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
autocmd FileType php setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
autocmd FileType coffee,javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
autocmd FileType python setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=120
autocmd FileType html,htmldjango,xhtml,haml setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=0
autocmd FileType sass,scss,css setlocal tabstop=2 shiftwidth=2 softtabstop=2 textwidth=120
" syntax support
autocmd Syntax javascript set syntax=jquery " JQuery syntax support
" js
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
"----------------- ----------------- ----------------- -----------------
" Rainbow parentheses for Lisp and variants
"----------------- ----------------- ----------------- -----------------
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'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
autocmd Syntax lisp,scheme,clojure,racket RainbowParenthesesToggle
" tabbar
let g:Tb_MaxSize = 2
let g:Tb_TabWrap = 1
hi Tb_Normal guifg=white ctermfg=white
hi Tb_Changed guifg=green ctermfg=green
hi Tb_VisibleNormal ctermbg=252 ctermfg=235
hi Tb_VisibleChanged guifg=green ctermbg=252 ctermfg=white
" -------- -------- -------- -------- -------- --------
" Tagbar
" -------- -------- -------- -------- -------- --------
let g:tagbar_left=0
let g:tagbar_width=30
let g:tagbar_autofocus = 1
let g:tagbar_sort = 0
let g:tagbar_compact = 1
" tag for markdown
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'sort' : 0,
\ 'kinds' : [
\ 'h:sections'
\ ]
\ }
let g:tagbar_type_html = {
\ 'ctagstype' : 'html',
\ 'kinds' : [
\ 'i:identifiers',
\ 'c:classes',
\ ],
\ }
" tag for coffee
if executable('coffeetags')
let g:tagbar_type_coffee = {
\ 'ctagsbin' : 'coffeetags',
\ 'ctagsargs' : '',
\ 'kinds' : [
\ 'f:functions',
\ 'o:object',
\ ],
\ 'sro' : ".",
\ 'kind2scope' : {
\ 'f' : 'object',
\ 'o' : 'object',
\ }
\ }
endif
" Nerd Tree
let NERDChristmasTree=0
let NERDTreeWinSize=30
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
" let NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\~$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos = "left"
let NERDTreeAutoDeleteBuffer=1
"
" nerdcommenter
let NERDSpaceDelims=1
" nmap <D-/> :NERDComToggleComment<cr>
let NERDCompactSexyComs=1
" ZenCoding
" Emmet
" let g:user_emmet_expandabbr_key='<C-j>'
let g:user_emmet_expandabbr_key='<Leader>h'
" 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 c setlocal omnifunc=ccomplete#Complete
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.erlang = '[a-zA-Z]\|:'
" SuperTab
" let g:SuperTabDefultCompletionType='context'
let g:SuperTabDefaultCompletionType = '<C-X><C-U>'
let g:SuperTabRetainCompletionType=2
"-------- -------- -------- -------- -------- --------
" ctrlp
"-------- -------- -------- -------- -------- --------
" let g:ctrlp_map = '<Leader>o'
set wildignore+=*/tmp/*,*.so,*.o,*.a,*.obj,*.swp,*.zip,*.pyc,*.pyo,*.class,.DS_Store " MacOSX/Linux
" let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
"-------- -------- -------- -------- -------- --------
" leaderf
"-------- -------- -------- -------- -------- --------
" <leader>f
" nnoremap <Leader>fcs :LeaderfColorscheme<CR>
" nnoremap <Leader>f? :LeaderfSelf<CR>
" nnoremap <Leader>fcs :LeaderfColorscheme<CR>
" nnoremap <Leader>fcs :LeaderfColorscheme<CR>
" nnoremap <Leader>fcs :LeaderfColorscheme<CR>
" nnoremap <Leader>fcs :LeaderfColorscheme<CR>
" nnoremap <Leader>fcs :LeaderfColorscheme<CR>
" nnoremap <Leader>fcs :LeaderfColorscheme<CR>
" Keybindings for plugin toggle
"绑定快捷键来激活or取消paste模式
" nnoremap <F9> :set invpaste paste?<CR>
nnoremap <Leader>p :set invpaste paste?<CR>
set pastetoggle=<F9>
"目录树和代码结构
nmap <Leader>tg :TagbarToggle<cr>
nmap <Leader>tn :NERDTreeToggle<cr>
" 文件撤销、重做
nmap <Leader>u :GundoToggle<cr>
" 垂直对齐线IndentGuidesToggle<cr>
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_guide_size=1
" let g:indent_guides_auto_colors=0
" autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg = red ctermbg = 3
" autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg = green ctermbg = 4
nmap <D-/> :
nnoremap <leader>a :Ack -i<space>
nnoremap <leader>v V`]
"-------- -------- -------- -------- -------- --------
"C,C++,Fortran,Python,java,sh等按<F5>编译运行
" exec !g++ % -o %<"
" exec ! ./%<"
"-------- -------- -------- -------- -------- --------
" quickfix有内容则自动弹出
augrou vimrc
autocmd QuickFixCmdPost * botright copen 8
augroup end
" 很多快捷键都是<leader>+字母,这样有点慢
:noremap <leader>1 :call asyncrun#quickfix_toggle(8,1)<cr>
:noremap <leader>2 :call asyncrun#quickfix_toggle(8,0)<cr>
map <F5> :call CompileAndRun()<CR>
func! CompileAndRun()
:cd %:p:h
exec "w"
if &filetype == 'c'
exec "AsyncRun! gcc % -o %<; time ./%<"
elseif &filetype == 'cpp'
exec "AsyncRun! g++ % -o %<; time ./%<"
elseif &filetype == 'html'
exec "AsyncRun!google-chrome %"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'python'
" exec "Asyncrun! python3 %; time ./%<"
exec "python3 %<"
elseif &filetype == 'markdown'
:MarkdownPreview
elseif &filetype == 'sh'
:!sh ./%
endif
endfunc
"-------- -------- -------- -------- -------- --------
"C,C++,Fortran,Python,java,Latex,sh等
"按F6编译但是一般不要求运行
"-------- -------- -------- -------- -------- --------
map <F6> :call CompileALL()<CR>
func! CompileALL()
:cd %:p:h
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
elseif &filetype == 'ncl'
exec "!ncl %"
elseif &filetype == 'java'
exec "!javac %"
elseif &filetype == 'fortran'
exec "!gfortran % -o %<"
elseif &filetype == 'python'
exec "!python %"
elseif &filetype == 'tex'
exec "!xelatex -shell-escape %<"
exec "!xelatex -shell-escape %<"
elseif &filetype == 'sh'
:!sh ./%
endif
endfunc
"-------- -------- -------- -------- -------- --------
"C,C++的调试<F10>
"-------- -------- -------- -------- -------- --------
"
map <C-r> :call Rungdb()<CR>
func! Rungdb()
:cd %:p:h
exec "w"
exec "!g++ % -g -o %<"
exec "!gdb ./%<"
endfunc
"-------- -------- -------- -------- -------- --------
" Asyncrun.vim
"-------- -------- -------- -------- -------- --------
" 编译
" :noremap <F7> :AsyncRun gcc "%" -o "%<" <cr>
"-------- -------- -------- -------- -------- --------
" Useful Functions
"-------- -------- -------- -------- -------- --------
" easier navigation between split windows
" nnoremap <c-j> <c-w>j
" nnoremap <c-k> <c-w>k
" nnoremap <c-h> <c-w>h
" nnoremap <c-l> <c-w>l
nnoremap <Leader>wj <c-w>j
nnoremap <Leader>wk <c-w>k
nnoremap <Leader>wh <c-w>h
nnoremap <Leader>wl <c-w>l
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
"
" w!! to sudo & write a file
cmap w!! %!sudo tee >/dev/null %
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Quickly Edit File
nmap <silent> <leader>td :e ~/workspaces/TODO.md<CR>
nmap <silent> <leader>bd :e ~/.vim/bundles.vim<CR>
" eggcache vim
nnoremap ; :
:command W w
:command WQ wq
:command Wq wq
:command Q q
:command Qa qa "退出全部窗口
:command QA qa
"-------- -------- -------- -------- -------- --------
" YouCompleteMe
"-------- -------- -------- -------- -------- --------
let g:deoplete#enable_at_startup = 1
" YCM 补全菜单配色
" 菜单
" highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5
" 选中项
" highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
" 补全功能在注释中同样有效
let g:ycm_complete_in_comments=1
" 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示
let g:ycm_confirm_extra_conf=0
" 开启 YCM 标签补全引擎
let g:ycm_collect_identifiers_from_tags_files=1
" 引入 C++ 标准库tags //于4月21更改于此
set tags+=/data/misc/software/misc./vim/stdcpp.tags
set tags+=~/.vim/stdcpp.tags
set tags+=~/.vim/sys_tags
"
"使用syntastic检查语法
let g:ycm_register_as_syntastic_checker = 1
let g:ycm_error_symbol='✗'
let g:ycm_warning_symbol='⚠'
"
" YCM 集成 OmniCppComplete 补全引擎,设置其快捷键
inoremap <leader>; <C-x><C-o>
" 补全内容不以分割子窗口形式出现,只显示补全列表
set completeopt-=preview
" 从第一个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=1
" 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_cache_omnifunc=0
" 语法关键字补全
let g:ycm_seed_identifiers_with_syntax=1
" 跳转到声明
nnoremap <Leader>gl :YcmCompleter GoToDeclaration<CR>
" 只能是 #include 或已打开的文件
" 跳转到定义
nnoremap <Leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <Leader>gd :YcmCompleter GoTo<CR>
nnoremap gd :YcmCompleter GoTo<CR>
"-------- -------- -------- -------- -------- --------
" ultisnips
"可.cpp 和 .h间切换
"-------- -------- -------- -------- -------- --------
let g:UltiSnipsSnippetDir = ["~/.vim/budle/UltiSnips"]
let g:UltiSnipsSnippetDirectories=["UltiSnips"]
let g:UltiSnipsExpandTrigger="<Leader><tab>"
let g:UltiSnipsJumpForwardTrigger="<Leader><tab>"
let g:UltiSnipsJumpBackwardTrigger="<Leader><s-tab>"
" -------- -------- -------- -------- -------- --------
" tasklist.vim
" -------- -------- -------- -------- -------- --------
nnoremap <Leader>tl :TaskList<cr>
"-------- -------- -------- -------- -------- --------
" rainbow
"-------- -------- -------- -------- -------- --------
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
" 不加入这行, 防止黑色括号出现, 很难识别
" \ ['black', 'SeaGreen3'],
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
let tlist_html_settings = 'html;h:Headers;o:Objects(ID);c:Classes'
let tlist_xhtml_settings = 'html;h:Headers;o:Objects(ID);c:Classes'
" -------- -------- -------- -------- -------- --------
" vim-devicons
" -------- -------- -------- -------- -------- --------
set guifont=Droid\ Sans\ Mono\ for\ Powerline\ Nerd\ Font\ Complete\ 12
" if exists('$ITERM_PROFILE')
" if exists('$TMUX')
" let &t_SI = '<Esc>[3 q'
" let &t_EI = '<Esc>[0 q'
" else
" let &t_SI = '<Esc>]50;CursorShape=1x7'
" let &t_EI = '<Esc>]50;CursorShape=0x7'
" endif
" endif
"
"
"
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" -------- -------- -------- -------- -------- --------
" ctags
" -------- -------- -------- -------- -------- --------
set tags+=/usr/include/tags
set tags+=~/.vim/systags
set tags+=~/.vim/x86_64-linux-gnu-systags
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_semantic_triggers = {
\ 'c' : ['->', '.','re![_a-zA-z0-9]'],
\ 'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s',
\ 're!\[.*\]\s'],
\ 'ocaml' : ['.', '#'],
\ 'cpp,objcpp' : ['->', '.', '::','re![_a-zA-Z0-9]'],
\ 'perl' : ['->'],
\ 'php' : ['->', '::'],
\ 'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir,go' : ['.'],
\ 'ruby' : ['.', '::'],
\ 'lua' : ['.', ':'],
\ 'erlang' : [':'],
\ }
let g:ycm_semantic_triggers.c = ['->', '.', ' ', '(', '[', '&',']']
" cpp_class_scope_highlight
let g:cpp_class_scope_highlight = 1
let g:cpp_experimental_template_highlight = 1
let c_no_curly_error = 1