-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc_ex
executable file
·1232 lines (1016 loc) · 49.3 KB
/
.vimrc_ex
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
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" ======================================================================================
" File : .vimrc
" Author : Wu Jie
" Last Change : 12/02/2009 | 12:02:28 PM | Wednesday,December
" Description :
" ======================================================================================
"/////////////////////////////////////////////////////////////////////////////
" exVim global settings
" NOTE: you should change to your own settings.
"/////////////////////////////////////////////////////////////////////////////
" set EX_DEV variable for linux
if has ("unix")
let $EX_DEV='~/exdev'
let g:ex_toolkit_path = $HOME.'/.toolkit'
" NOTE: mac is unix like system, but to use gawk,id-utils correctly, we need to manually set the export path.
if has ("mac")
let $PATH='/usr/local/bin/:'.$PATH
endif
else " else if win32 or other system, just set the toolkit path.
let g:ex_toolkit_path = $EX_DEV.'/tools/exvim/toolkit'
endif
" put your own user name here
let g:ex_usr_name = "Wu Jie"
"/////////////////////////////////////////////////////////////////////////////
" General
"/////////////////////////////////////////////////////////////////////////////
set nocompatible " Use Vim settings, rather then Vi settings (much better!). This must be first, because it changes other options as a side effect.
set langmenu=none " always use English menu
" always use english for anaything in vim-editor.
if has ("win32")
silent exec "language english"
elseif has ("mac")
silent exec "language en_US"
else
silent exec "language en_US.utf8"
endif
au FileType c,cpp,cs,swig set nomodeline " this will avoid bug in my project with namespace ex, the vim will tree ex:: as modeline.
" source $VIMRUNTIME/vimrc_example.vim
behave xterm " set mouse behavior as xterm
"set path=.,/usr/include/*,, " where gf, ^Wf, :find will search
set backup " make backup file and leave it around
"UNUSED: set backupdir=%tmp%
"UNUSED: set directory=.,%tmp%
" setup back and swap directory
let data_dir = $HOME.'/.data/'
let backup_dir = data_dir . 'backup'
let swap_dir = data_dir . 'swap'
if finddir(data_dir) == ''
silent call mkdir(data_dir)
endif
if finddir(backup_dir) == ''
silent call mkdir(backup_dir)
endif
if finddir(swap_dir) == ''
silent call mkdir(swap_dir)
endif
set backupdir=$HOME/.data/backup " where to put backup file
set directory=$HOME/.data/swap " where to put swap file
unlet data_dir
unlet backup_dir
unlet swap_dir
" programming related
set tags+=./tags,./../tags,./**/tags,tags " which tags files CTRL-] will find
set makeef=error.err " the errorfile for :make and :grep
" NOTE: viminfo
" for MS-DOS, Windows and OS/2: '20,<50,s10,h,rA:,rB:,
" for Amiga: '20,<50,s10,h,rdf0:,rdf1:,rdf2:
" for others: '20,<50,s10,h
set viminfo+=! " make sure it can save viminfo
filetype on " enable file type detection
filetype plugin on " enable loading the plugin for appropriate file type
" Redefine the shell redirection operator to receive both the stderr messages
" and stdout messages
set shellredir=>%s\ 2>&1
set history=50 " keep 50 lines of command line history
set updatetime=1000 " default = 4000
set autoread " auto read same-file change ( better for vc/vim change )
" XXX
"set isk+=$,%,#,- " none of these should be word dividers
" FIXME: no fix yet in vim72
" there have a bug with visual copy, shows the there is nothing in register *
" set clipboard=unnamed " use clipboard register '*'(unnamed) for all y, d, c, p ops, use autoselect to avoid selection p bugs.
" enlarge maxmempattern from 1000 to ... (2000000 will give it without limit)
set maxmempattern=1000
" DISABLE: done in exQuickFix {
" set quick fix error format
" default errorformat = %f(%l) : %t%*\D%n: %m,%*[^"]"%f"%*\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m
"set errorformat+=%D%\\d%\\+\>------\ %.%#Project:\ %f%\\,%.%# " msvc 2005 error-entering
"set errorformat+=%D%\\d%\\+\>------\ %.%#Project:\ %f%\\,%.%# " msvc 2005 error-entering
"set errorformat+=%X%\\d%\\+\>%.%#%\\d%\\+\ error(s)%.%#%\\d%\\+\ warning(s) " msvc 2005 error-leaving
"set errorformat+=%\\d%\\+\>%f(%l)\ :\ %t%*\\D%n:\ %m " msvc 2005 error-format
"set errorformat+=%f(%l\\,%c):\ %m " fxc shader error-format
" } DISABLE end
"/////////////////////////////////////////////////////////////////////////////
" xterm settings
"/////////////////////////////////////////////////////////////////////////////
if &term =~ "xterm"
set mouse=a
endif
"/////////////////////////////////////////////////////////////////////////////
" Variable settings ( set all )
"/////////////////////////////////////////////////////////////////////////////
" ------------------------------------------------------------------
" Desc: Visual
" ------------------------------------------------------------------
set showmatch " show matching paren
set matchtime=0 " 0 second to show the matching paren ( much faster )
set nu " Show LineNumber
set scrolloff=0 " minimal number of screen lines to keep above and below the cursor
set nowrap " I don't like wrap, cause in split window mode, it feel strange
" set default guifont
if has("gui_running")
" check and determine the gui font after GUIEnter.
" NOTE: getfontname function only works after GUIEnter.
au GUIEnter * call s:SetGuiFont()
endif
" set guifont
function s:SetGuiFont()
if has("gui_gtk2")
" set guifont=Luxi\ Mono\ 13
set guifont=Inconsolata\ 14
" set guifont=Monaco\ 12
elseif has("x11")
" Also for GTK 1
set guifont=*-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-*
elseif has("mac")
if getfontname( "Bitstream_Vera_Sans_Mono" ) != ""
set guifont=Bitstream\ Vera\ Sans\ Mono:h13
elseif getfontname( "DejaVu\ Sans\ Mono" ) != ""
set guifont=DejaVu\ Sans\ Mono:h13
endif
elseif has("gui_win32")
let font_name = ""
if getfontname( "Bitstream_Vera_Sans_Mono" ) != ""
set guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
let font_name = "Bitstream_Vera_Sans_Mono"
elseif getfontname( "Consolas" ) != ""
set guifont=Consolas:h11:cANSI " this is the default visual studio font
let font_name = "Consolas"
else
set guifont=Lucida_Console:h10:cANSI
let font_name = "Lucida_Console"
endif
silent exec "nnoremap <unique> <M-F1> :set guifont=".font_name.":h11:cANSI<CR>"
endif
endfunction
" color scheme define
if has("gui_running")
" silent exec "colorscheme ex"
silent exec "colorscheme ex_lightgray"
else " if we are in terminal mode
" NOTE: you cannot use if has('mac') to detect platform in terminal mode.
silent exec "colorscheme default"
" silent exec "colorscheme darkblue"
endif
" ------------------------------------------------------------------
" Desc: Vim UI
" ------------------------------------------------------------------
set wildmenu " turn on wild menu, try typing :h and press <Tab>
set showcmd " display incomplete commands
set cmdheight=1 " 1 screen lines to use for the command-line
set ruler " show the cursor position all the time
set hid " allow to change buffer without saving
set shortmess=atI " shortens messages to avoid 'press a key' prompt
set lazyredraw " do not redraw while executing macros (much faster)
set display+=lastline " for easy browse last line with wrap text
set laststatus=2 " always have status-line
" TODO: set statusline= " statusline with different color 'User1-9'
" Set window's width to 130 columns and height to 40 rows
" (if it's GUI)
if has("gui_running")
set lines=40 columns=130
endif
set showfulltag " show tag with function protype.
set guioptions+=b " Present the bottom scrollbar when the longest visible line exceen the window
" disable menu & toolbar
set guioptions-=m
set guioptions-=T
"set encoding=japan
"set termencoding=cp932
"set encoding=cp932
"set termencoding=cp932
"set grepprg=grep\ -n
" set default encoding to utf-8
set encoding=utf-8
set termencoding=utf-8
" ------------------------------------------------------------------
" Desc: Text edit
" ------------------------------------------------------------------
set ai " autoindent
set si " smartindent
set backspace=indent,eol,start " allow backspacing over everything in insert mode
" indent options
" see help cinoptions-values for more details
set cinoptions=>s,e0,n0,f0,{0,}0,^0,:0,=s,l0,b0,g0,hs,ps,ts,is,+s,c3,C0,0,(0,us,U0,w0,W0,m0,j0,)20,*30
" default '0{,0},0),:,0#,!^F,o,O,e' disable 0# for not ident preprocess
" set cinkeys=0{,0},0),:,!^F,o,O,e
" Official diff settings
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary -w '
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
silent execute '!' . 'diff ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
endfunction
set cindent shiftwidth=4 " Set cindent on to autoinent when editing C/C++ file, with 4 shift width
set tabstop=4 " Set tabstop to 4 characters
set expandtab " Set expandtab on, the tab will be change to space automaticaly
" Set Number format to null(default is octal) , when press CTRL-A on number
" like 007, it would not become 010
set nf=
" In Visual Block Mode, cursor can be positioned where there is no actual character
set ve=block
" ------------------------------------------------------------------
" Desc: Fold text
" ------------------------------------------------------------------
set foldmethod=marker foldmarker={,} foldlevel=9999
set diffopt=filler,context:9999
" ------------------------------------------------------------------
" Desc: Search
" ------------------------------------------------------------------
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
set incsearch " do incremental searching
set ignorecase " Set search/replace pattern to ignore case
set smartcase " Set smartcase mode on, If there is upper case character in the search patern, the 'ignorecase' option will be override.
" set this to use id-utils for global search
set grepprg=lid\ -Rgrep\ -s
set grepformat=%f:%l:%m
" ------------------------------------------------------------------
" Desc: Syntax
" ------------------------------------------------------------------
let c_gnu = 1
let c_no_curly_error = 1
"let c_no_bracket_error = 1
"/////////////////////////////////////////////////////////////////////////////
" Key Mappings
"/////////////////////////////////////////////////////////////////////////////
" NOTE: F10 looks like have some feature, when map with F10, the map will take no effects
" Don't use Ex mode, use Q for formatting
map Q gq
" DISABLE: it is no-use now, also we use \fc for exProject {
" Set new Rgrep as the grep to search patterns on the C/C++ files as default
"command -nargs=+ Rgrep :grep -r --include="*.cpp" --include="*.c" --include="*.hpp" --include="*.h" <q-args> *
"map <Leader>fc :call <SID>Grep_Cfiles()<CR>
"function s:Grep_Cfiles()
" let l_str=input("Input the keyword to be searched: ")
" exec ":grep -r --include=\"*.cpp\" --include=\"*.c\" --include=\"*.hpp\" --include=\"*.h\" " . l_str . " *"
"endfunction
" } DISABLE end
" define the copy/paste judged by clipboard
if &clipboard ==# "unnamed"
" fix the visual paste bug in vim
" vnoremap <silent>p :call g:()<CR>
else
" general copy/paste.
" NOTE: y,p,P could be mapped by other key-mapping
map <unique> <leader>y "*y
map <unique> <leader>p "*p
map <unique> <leader>P "*P
endif
" F8: Set Search pattern highlight on/off
nnoremap <unique> <F8> :let @/=""<CR>
" fast encoding change.
if has("gui_running") " the <alt> key is only available in gui mode.
" DISABLE: done in s:SetGuiFont() function {
" M-F1: Switch to English Mode (Both Enconding and uiFont)
" nnoremap <unique> <M-F1> :set guifont=Bitstream_Vera_Sans_Mono:h10:cANSI<CR>
" nnoremap <unique> <M-F1> :set guifont=Consolas:h11:cANSI<CR>
" } DISABLE end
" M-F2: Switch to Chinese Mode (Both Enconding and uiFont)
nnoremap <unique> <M-F2> :set guifont=NSimSun:h10:cGB2312<CR>
" M-F3: Switch to Japanese Mode
nnoremap <unique> <M-F3> :set guifont=MS_Gothic:h10:cSHIFTJIS<CR>
else
" <leader>F1: Switch to English Mode (Both Enconding and uiFont)
" nnoremap <unique> <M-F1> :set guifont=Bitstream_Vera_Sans_Mono:h10:cANSI<CR>
nnoremap <unique> <M-F1> :set guifont=Consolas:h11:cANSI<CR>
" <leader>F2: Switch to Chinese Mode (Both Enconding and uiFont)
nnoremap <unique> <M-F2> :set guifont=NSimSun:h10:cGB2312<CR>
" <leader>F3: Switch to Japanese Mode
nnoremap <unique> <M-F3> :set guifont=MS_Gothic:h10:cSHIFTJIS<CR>
endif
" map Ctrl-Tab to switch window
nnoremap <unique> <S-Up> <C-W><Up>
nnoremap <unique> <S-Down> <C-W><Down>
nnoremap <unique> <S-Left> <C-W><Left>
nnoremap <unique> <S-Right> <C-W><Right>
" Move in fold
noremap <unique> z<Up> zk
noremap <unique> z<Down> zj
if has("gui_running") " the <alt> key is only available in gui mode.
noremap <unique> <M-Up> zk
noremap <unique> <M-Down> zj
endif
" Easy Diff goto
noremap <unique> <C-Up> [c
noremap <unique> <C-k> [c
noremap <unique> <C-Down> ]c
noremap <unique> <C-j> ]c
" VimTip #412: Easy menu-style switch between files with a simple map
" map <C-b> :buffers<CR>:e #
" Like J, I make a de-joint for command mode
" nmap <C-j> a<CR><ESC>
" Enhance '<' '>' , do not need to reselect the block after shift it.
vnoremap <unique> < <gv
vnoremap <unique> > >gv
" Fold close & Fold open
noremap <unique> <kPlus> zo
noremap <unique> <kMinus> zc
" map Up & Down to gj & gk, helpful for wrap text edit
noremap <unique> <Up> gk
noremap <unique> <Down> gj
" map for completion see :help ins-completion for whole completions
" search tags
inoremap <unique> <c-]> <C-X><C-]>
" search in current files, preview first. remove the original c-p
inoremap <unique> <c-p> <C-X><C-P>
" VimTip 329: A map for swapping words
" http://vim.sourceforge.net/tip_view.php?tip_id=
" Then when you put the cursor on or in a word, press "\sw", and
" the word will be swapped with the next word. The words may
" even be separated by punctuation (such as "abc = def").
nnoremap <unique> <silent><leader>sw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o>
"/////////////////////////////////////////////////////////////////////////////
" Command
"/////////////////////////////////////////////////////////////////////////////
" perforce key mapping
" TODO: should go to exSourceControl someday. {
" let g:proj_run1='!p4 edit %f'
" nmap <Leader>po :silent !p4 edit %<CR>
" nmap <Leader>pr :silent !p4 revert %<CR>
command Checkout silent exec '!p4 edit ' . fnamemodify( bufname('%'), ':p' )
command Revert silent exec '!p4 revert ' . fnamemodify( bufname('%'), ':p' )
command Add silent exec '!p4 add ' . fnamemodify( bufname('%'), ':p' )
command Delete silent exec '!p4 delete ' . fnamemodify( bufname('%'), ':p' )
command Changelist :silent !p4 change
command ShowChangelist :!p4 changes -s pending -u jwu
" } TODO end
"/////////////////////////////////////////////////////////////////////////////
" Auto Command
"/////////////////////////////////////////////////////////////////////////////
" ------------------------------------------------------------------
" Desc: Only do this part when compiled with support for autocommands.
" ------------------------------------------------------------------
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
" autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
endif " has("autocmd")
" ------------------------------------------------------------------
" Desc: Buffer
" ------------------------------------------------------------------
au BufNewFile,BufEnter * set cpoptions+=d " NOTE: ctags find the tags file from the current path instead of the path of currect file
au BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full)
au BufNewFile,BufRead *.avs set syntax=avs " for avs syntax file.
au FileType python call s:CheckIfExpandTab() " if edit python scripts, check if have \t. ( python said: the programme can only use \t or not, but can't use them together )
function s:CheckIfExpandTab()
let has_noexpandtab = search('^\t','wn')
let has_expandtab = search('^ ','wn')
"
if has_noexpandtab && has_expandtab
let idx = inputlist ( ["ERROR: current file exists both expand and noexpand TAB, python can only use one of these two mode in one file.\nSelect Tab Expand Type:",
\ '1. expand (tab=space, recommended)',
\ '2. noexpand (tab=\t, currently have risk)',
\ '3. do nothing (I will handle it by myself)'])
let tab_space = printf('%*s',&tabstop,'')
if idx == 1
let has_noexpandtab = 0
let has_expandtab = 1
silent exec '%s/\t/' . tab_space . '/g'
elseif idx == 2
let has_noexpandtab = 1
let has_expandtab = 0
silent exec '%s/' . tab_space . '/\t/g'
else
return
endif
endif
"
if has_noexpandtab == 1 && has_expandtab == 0
echomsg 'substitute space to TAB...'
set noexpandtab
echomsg 'done!'
elseif has_noexpandtab == 0 && has_expandtab == 1
echomsg 'substitute TAB to space...'
set expandtab
echomsg 'done!'
else
" it may be a new file
" we use original vim setting
endif
endfunction
" DISABLE {
" NOTE: may have problem with exUtility
" Change current directory to the file of the buffer ( from Script#65"CD.vim"
" au BufEnter * execute ":lcd " . expand("%:p:h")
" } DISABLE end
" ------------------------------------------------------------------
" Desc:
" ------------------------------------------------------------------
if has("gui_running")
if has("win32")
" au GUIEnter * simalt ~x " Maximize window when enter vim
" set a fixed size of vim
if exists("+lines")
set lines=55
endif
if exists("+columns")
set columns=125
endif
elseif has("unix")
" TODO: no way right now
endif
endif
" ------------------------------------------------------------------
" Desc: file types
" ------------------------------------------------------------------
" Disable auto-comment for c/cpp, lua, javascript, c# and vim-script
au FileType c,cpp,javascript set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,f://
au FileType cs set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,f:///,f://
au FileType vim set comments=sO:\"\ -,mO:\"\ \ ,eO:\"\",f:\"
au FileType lua set comments=f:--
"/////////////////////////////////////////////////////////////////////////////
" Plugin Configurations
"/////////////////////////////////////////////////////////////////////////////
" ------------------------------------------------------------------
" Desc: exUtility
" ------------------------------------------------------------------
" quick substitue h1 -> h2
nnoremap <unique> <silent><leader>sub :%s/<c-r>q/<c-r>w/g<CR><c-o>
vnoremap <unique> <silent><leader>sub :s/<c-r>q/<c-r>w/g<CR><c-o>
" edit current vimentry
nnoremap <unique> <leader>ve :call exUtility#EditVimEntry ()<CR>
" map for quick add special comments
nnoremap <unique> <leader>ws :SEG<CR>
nnoremap <unique> <leader>wd :DEF<CR>
nnoremap <unique> <leader>we :SEP<CR>
nnoremap <unique> <leader>wc :DEC<CR>
nnoremap <unique> <leader>wh :HEADER<CR>
" F9: Insert/Remove macro extend ("\") after all the lines of the selection
vnoremap <unique> <F9> :call exUtility#InsertRemoveExtend()<CR>
" F12: Insert '#if 0' and '#endif' between the selection
vnoremap <unique> <F12> :call exUtility#InsertIFZero()<CR>
nnoremap <unique> <F12> :call exUtility#RemoveIFZero()<CR>
" switch between edit and ex-plugin window
nnoremap <unique> <silent><Leader><Tab> :call exUtility#SwitchBuffer()<CR>
" close ex-plugin window when in edit window
nmap <unique> <silent><Leader><ESC> :call exUtility#SwitchBuffer()<CR><ESC>
" change the original file jump method to this one
nnoremap <unique> gf :call exUtility#QuickFileJump()<CR>
" VimTip #401: A mapping for easy switching between buffers
" DISABLE: there has a bug, in window (not fullscree) mode, some times the buffer will jump to other display screen ( if you use double screen ). {
" nmap <silent> <C-Right> :bn!<CR>
" nmap <silent> <C-Left> :bp!<CR>
" } DISABLE end
nnoremap <unique> <silent> <C-Right> :call exUtility#GotoBuffer('next')<CR>
nnoremap <unique> <silent> <C-Left> :call exUtility#GotoBuffer('prev')<CR>
nnoremap <unique> <silent> <C-Tab> :call exUtility#SwapToLastEditBuffer()<CR>
" map exUtility#Kwbd(1) to \bd will close buffer and keep window
nnoremap <unique> <Leader>bd :call exUtility#Kwbd(1)<CR>
nnoremap <unique> <C-F4> :call exUtility#Kwbd(1)<CR>
" quick highlight
" NOTE: only gui mode can have alt, in terminal we have to use other mapping
if has("gui_running") " gui mode
if has ("mac")
nnoremap <unique> <silent> ¡ :call exUtility#Highlight_Normal(1)<CR>
nnoremap <unique> <silent> ™ :call exUtility#Highlight_Normal(2)<CR>
nnoremap <unique> <silent> £ :call exUtility#Highlight_Normal(3)<CR>
nnoremap <unique> <silent> ¢ :call exUtility#Highlight_Normal(4)<CR>
vnoremap <unique> <silent> ¡ :call exUtility#Highlight_Visual(1)<CR>
vnoremap <unique> <silent> ™ :call exUtility#Highlight_Visual(2)<CR>
vnoremap <unique> <silent> £ :call exUtility#Highlight_Visual(3)<CR>
vnoremap <unique> <silent> ¢ :call exUtility#Highlight_Visual(4)<CR>
nnoremap <unique> <silent> º :call exUtility#HighlightCancle(0)<CR>
else
nnoremap <unique> <silent> <M-1> :call exUtility#Highlight_Normal(1)<CR>
nnoremap <unique> <silent> <M-2> :call exUtility#Highlight_Normal(2)<CR>
nnoremap <unique> <silent> <M-3> :call exUtility#Highlight_Normal(3)<CR>
nnoremap <unique> <silent> <M-4> :call exUtility#Highlight_Normal(4)<CR>
vnoremap <unique> <silent> <M-1> :call exUtility#Highlight_Visual(1)<CR>
vnoremap <unique> <silent> <M-2> :call exUtility#Highlight_Visual(2)<CR>
vnoremap <unique> <silent> <M-3> :call exUtility#Highlight_Visual(3)<CR>
vnoremap <unique> <silent> <M-4> :call exUtility#Highlight_Visual(4)<CR>
nnoremap <unique> <silent> <M-0> :call exUtility#HighlightCancle(0)<CR>
endif
else " terminal mode
nnoremap <unique> <silent> <leader>h1 :call exUtility#Highlight_Normal(1)<CR>
nnoremap <unique> <silent> <leader>h2 :call exUtility#Highlight_Normal(2)<CR>
nnoremap <unique> <silent> <leader>h3 :call exUtility#Highlight_Normal(3)<CR>
nnoremap <unique> <silent> <leader>h4 :call exUtility#Highlight_Normal(4)<CR>
vnoremap <unique> <silent> <leader>h1 :call exUtility#Highlight_Visual(1)<CR>
vnoremap <unique> <silent> <leader>h2 :call exUtility#Highlight_Visual(2)<CR>
vnoremap <unique> <silent> <leader>h3 :call exUtility#Highlight_Visual(3)<CR>
vnoremap <unique> <silent> <leader>h4 :call exUtility#Highlight_Visual(4)<CR>
nnoremap <unique> <silent> <leader>h0 :call exUtility#HighlightCancle(0)<CR>
endif
nnoremap <unique> <silent> <Leader>0 :call exUtility#HighlightCancle(0)<CR>
nnoremap <unique> <silent> <Leader>1 :call exUtility#HighlightCancle(1)<CR>
nnoremap <unique> <silent> <Leader>2 :call exUtility#HighlightCancle(2)<CR>
nnoremap <unique> <silent> <Leader>3 :call exUtility#HighlightCancle(3)<CR>
nnoremap <unique> <silent> <Leader>4 :call exUtility#HighlightCancle(4)<CR>
" copy only full path name
nnoremap <unique> <silent> <leader>y1 :call exUtility#Yank( fnamemodify(bufname('%'),":p:h") )<CR>
" copy only file name
nnoremap <unique> <silent> <leader>y2 :call exUtility#Yank( fnamemodify(bufname('%'),":p:t") )<CR>
" copy full path + filename
nnoremap <unique> <silent> <leader>y3 :call exUtility#Yank( fnamemodify(bufname('%'),":p") )<CR>
" copy path + filename for code
nnoremap <unique> <silent> <leader>yb :call exUtility#YankBufferNameForCode()<CR>
" copy path for code
nnoremap <unique> <silent> <leader>yp :call exUtility#YankFilePathForCode()<CR>
" VimTip 311: Open the folder containing the currently open file
" http://vim.sourceforge.net/tip_view.php?tip_id=
"
" Occasionally, on windows, I have files open in gvim, that the folder for
" that file is not open. This key map opens the folder that contains the
" currently open file. The expand() is so that we don't try to open the
" folder of an anonymous buffer, we would get an explorer error dialog in
" that case.
"
if has("gui_running")
if has("win32")
" Open the folder containing the currently open file. Double <CR> at end
" is so you don't have to hit return after command. Double quotes are
" not necessary in the 'explorer.exe %:p:h' section.
" nnoremap <silent> <C-F5> :if expand("%:p:h") != ""<CR>:!start explorer.exe %:p:h<CR>:endif<CR><CR>
" explore the vimfile directory
nnoremap <unique> <silent> <C-F5> :call exUtility#Yank( getcwd() . '\' . g:exES_VimfilesDirName )<CR>
nnoremap <unique> <silent> <M-F5> :call exUtility#Explore( getcwd() . '\' . g:exES_VimfilesDirName )<CR>
" explore the cwd directory
nnoremap <unique> <silent> <C-F6> :call exUtility#Yank(getcwd())<CR>
nnoremap <unique> <silent> <M-F6> :call exUtility#Explore(getcwd())<CR>
" explore the diretory current file in
nnoremap <unique> <silent> <C-F7> :call exUtility#Yank(expand("%:p:h"))<CR>
nnoremap <unique> <silent> <M-F7> :call exUtility#Explore(expand("%:p:h"))<CR>
endif
endif
" inherit
nnoremap <unique> <silent> <Leader>gv :call exUtility#ViewInheritsImage()<CR>
" mark (special) text
let g:ex_todo_keyword = 'NOTE REF EXAMPLE SAMPLE CHECK TIPS HINT'
let g:ex_comment_lable_keyword = 'DELME TEMP MODIFY ADD KEEPME DISABLE TEST ' " for editing
let g:ex_comment_lable_keyword .= 'ERROR DEBUG CRASH DUMMY UNUSED TESTME ' " for testing
let g:ex_comment_lable_keyword .= 'FIXME BUG HACK OPTME HARDCODE REFACTORING DUPLICATE REDUNDANCY PATCH ' " for refactoring
vnoremap <unique> <Leader>mk :MK
nnoremap <unique> <Leader>mk :call exUtility#RemoveSpecialMarkText() <CR>
" register buffer names of plugins.
" let g:ex_plugin_registered_bufnames = ["-MiniBufExplorer-","__Tag_List__","\[Lookup File\]", "\[fuf\]", "\[BufExplorer\]"]
let g:ex_plugin_registered_bufnames = ["__Tag_List__","\[Lookup File\]", "\[fuf\]", "\[BufExplorer\]"]
" register filetypes of plugins.
let g:ex_plugin_registered_filetypes = ["ex_plugin","ex_project","taglist","nerdtree"]
" default languages
let g:ex_default_langs = ['c', 'cpp', 'c#', 'javascript', 'java', 'shader', 'python', 'lua', 'vim', 'uc', 'matlab', 'wiki', 'ini', 'make', 'sh', 'batch', 'debug', 'qt', 'swig' ]
" DISABLE: auto highlight cursor word
" let g:ex_auto_hl_cursor_word = 1
" set exvim language map
call exUtility#AddLangMap ( 'exvim', 'javascript', ['as'] )
call exUtility#AddLangMap ( 'exvim', 'maxscript', ['ms'] )
call exUtility#AddLangMap ( 'exvim', 'lua', ['wlua'] )
" To let the extension language works correctly, you need to put toolkit/ctags/.ctags into your $HOME directory
" set ctags language map
" call exUtility#AddLangMap ( 'ctags', 'ini', ['ini'] )
" call exUtility#AddLangMap ( 'ctags', 'uc', ['uc'] )
call exUtility#AddLangMap ( 'ctags', 'maxscript', ['ms'] )
" update custom highlights
function g:ex_CustomHighlight()
" ========================================================
" ShowMarks
" ========================================================
" " For marks a-z
" hi clear ShowMarksHLl
" hi ShowMarksHLl term=bold cterm=none ctermbg=LightBlue gui=none guibg=LightBlue
" " For marks A-Z
" hi clear ShowMarksHLu
" hi ShowMarksHLu term=bold cterm=bold ctermbg=LightRed ctermfg=DarkRed gui=bold guibg=LightRed guifg=DarkRed
" " For all other marks
" hi clear ShowMarksHLo
" hi ShowMarksHLo term=bold cterm=bold ctermbg=LightYellow ctermfg=DarkYellow gui=bold guibg=LightYellow guifg=DarkYellow
" " For multiple marks on the same line.
" hi clear ShowMarksHLm
" hi ShowMarksHLm term=bold cterm=none ctermbg=LightBlue gui=none guibg=SlateBlue
" ========================================================
" MiniBufExplorer
" ========================================================
" " for buffers that have NOT CHANGED and are NOT VISIBLE.
" hi MBENormal ctermbg=LightGray ctermfg=DarkGray guibg=LightGray guifg=DarkGray
" " for buffers that HAVE CHANGED and are NOT VISIBLE
" hi MBEChanged ctermbg=Red ctermfg=DarkRed guibg=Red guifg=DarkRed
" " buffers that have NOT CHANGED and are VISIBLE
" hi MBEVisibleNormal term=bold cterm=bold ctermbg=Gray ctermfg=Black gui=bold guibg=Gray guifg=Black
" " buffers that have CHANGED and are VISIBLE
" hi MBEVisibleChanged term=bold cterm=bold ctermbg=DarkRed ctermfg=Black gui=bold guibg=DarkRed guifg=Black
" ========================================================
" TagList
" ========================================================
" TagListTagName - Used for tag names
hi MyTagListTagName term=bold cterm=none ctermfg=Black ctermbg=DarkYellow gui=none guifg=Black guibg=#ffe4b3
" TagListTagScope - Used for tag scope
hi MyTagListTagScope term=NONE cterm=NONE ctermfg=Blue gui=NONE guifg=Blue
" TagListTitle - Used for tag titles
hi MyTagListTitle term=bold cterm=bold ctermfg=DarkRed ctermbg=LightGray gui=bold guifg=DarkRed guibg=LightGray
" TagListComment - Used for comments
hi MyTagListComment ctermfg=DarkGreen guifg=DarkGreen
" TagListFileName - Used for filenames
hi MyTagListFileName term=bold cterm=bold ctermfg=Black ctermbg=LightBlue gui=bold guifg=Black guibg=LightBlue
" ========================================================
" special color settings
" ========================================================
if exists('g:colors_name') && g:colors_name == 'ex_lightgray'
" ex plugins
hi ex_SynSearchPattern gui=bold guifg=DarkRed guibg=Gray term=bold cterm=bold ctermfg=DarkRed ctermbg=Gray
hi exMH_GroupNameEnable term=bold cterm=bold ctermfg=DarkRed ctermbg=Gray gui=bold guifg=DarkRed guibg=Gray
hi exMH_GroupNameDisable term=bold cterm=bold ctermfg=Red ctermbg=DarkGray gui=bold guifg=DarkGray guibg=Gray
" other plugins
hi MBEVisibleNormal term=bold cterm=bold ctermbg=DarkGray ctermfg=Black gui=bold guibg=DarkGray guifg=Black
hi MBENormal ctermbg=Gray ctermfg=DarkGray guibg=Gray guifg=DarkGray
hi MyTagListTitle term=bold cterm=bold ctermfg=DarkRed ctermbg=Gray gui=bold guifg=DarkRed guibg=Gray
endif
endfunction
" ------------------------------------------------------------------
" Desc: exTagSelect
" ------------------------------------------------------------------
nnoremap <unique> <silent> <Leader>ts :ExtsSelectToggle<CR>
nnoremap <unique> <silent> <Leader>tg :ExtsGoDirectly<CR>
nnoremap <unique> <silent> <Leader>] :ExtsGoDirectly<CR>
let g:exTS_backto_editbuf = 0
let g:exTS_close_when_selected = 1
let g:exTS_window_direction = 'bel'
" ------------------------------------------------------------------
" Desc: exGlobalSearch
" ------------------------------------------------------------------
nnoremap <unique> <silent> <Leader>gs :ExgsSelectToggle<CR>
nnoremap <unique> <silent> <Leader>gq :ExgsQuickViewToggle<CR>
nnoremap <unique> <silent> <Leader>gg :ExgsGoDirectly<CR>
nnoremap <unique> <silent> <Leader>gn :ExgsGotoNextResult<CR>
nnoremap <unique> <silent> <Leader>gp :ExgsGotoPrevResult<CR>
nnoremap <unique> <Leader><S-f> :GS
let g:exGS_backto_editbuf = 0
let g:exGS_close_when_selected = 0
let g:exGS_window_direction = 'bel'
let g:exGS_auto_sort = 1
let g:exGS_lines_for_autosort = 200
" ------------------------------------------------------------------
" Desc: exSymbolTable
" ------------------------------------------------------------------
nnoremap <unique> <silent> <Leader>ss :ExslSelectToggle<CR>
nnoremap <unique> <silent> <Leader>sq :ExslQuickViewToggle<CR>
nnoremap <unique> <silent> <Leader>sg :ExslGoDirectly<CR>
" NOTE: the / can be mapped to other script ( for example exSearchComplete ), so here use nmap instead of nnoremap
if has("gui_running") " the <alt> key is only available in gui mode.
if has ("mac")
nmap <unique> Ò :ExslQuickSearch<CR>/
else
nmap <unique> <M-L> :ExslQuickSearch<CR>/
endif
endif
let g:exSL_SymbolSelectCmd = 'TS'
" ------------------------------------------------------------------
" Desc: exJumpStack
" ------------------------------------------------------------------
nnoremap <unique> <silent> <Leader>tt :ExjsToggle<CR>
nnoremap <unique> <silent> <Leader>tb :BackwardStack<CR>
nnoremap <unique> <silent> <Leader>tf :ForwardStack<CR>
nnoremap <unique> <silent> <BS> :BackwardStack<CR>
if has("gui_running") " the <alt> key is only available in gui mode.
noremap <unique> <M-Left> :BackwardStack<CR>
noremap <unique> <M-Right> :ForwardStack<CR>
endif
" ------------------------------------------------------------------
" Desc: exCscope
" ------------------------------------------------------------------
nnoremap <unique> <silent> <F2> :CSIC<CR>
nnoremap <unique> <silent> <Leader>ci :CSID<CR>
nnoremap <unique> <silent> <F3> :ExcsParseFunction<CR>
nnoremap <unique> <silent> <Leader>cd :CSDD<CR>
nnoremap <unique> <silent> <Leader>cc :CSCD<CR>
nnoremap <unique> <silent> <Leader>cs :ExcsSelectToggle<CR>
nnoremap <unique> <silent> <Leader>cq :ExcsQuickViewToggle<CR>
let g:exCS_backto_editbuf = 0
let g:exCS_close_when_selected = 0
let g:exCS_window_direction = 'bel'
let g:exCS_window_width = 48
" ------------------------------------------------------------------
" Desc: exQuickFix
" ------------------------------------------------------------------
nnoremap <unique> <silent> <leader>qf :ExqfSelectToggle<CR>
nnoremap <unique> <silent> <leader>qq :ExqfQuickViewToggle<CR>
let g:exQF_backto_editbuf = 0
let g:exQF_close_when_selected = 0
let g:exQF_window_direction = 'bel'
" ------------------------------------------------------------------
" Desc: exMacroHighlight
" ------------------------------------------------------------------
nnoremap <unique> <silent> <Leader>aa :ExmhSelectToggle<CR>
nnoremap <unique> <silent> <Leader>ae :ExmhHL 1 <CR>
nnoremap <unique> <silent> <Leader>ad :ExmhHL 0 <CR>
" ------------------------------------------------------------------
" Desc: exProject
" ------------------------------------------------------------------
" NOTE: the / can be mapped to other script ( for example exSearchComplete ), so here use nmap instead of nnoremap
" NOTE: M-O equal to A-S-o, the S-o equal to O
if has("gui_running") " the <alt> key is only available in gui mode.
if has ("mac")
nmap <unique> Ø :EXProject<CR>:redraw<CR>/
nnoremap <unique> <silent> ∏ :EXProject<CR>
else
nmap <unique> <M-O> :EXProject<CR>:redraw<CR>/
nnoremap <unique> <silent> <M-P> :EXProject<CR>
endif
endif
nnoremap <unique> <leader>ff :EXProject<CR>:redraw<CR>/\[\l*\]\zs.*
nnoremap <unique> <leader>fd :EXProject<CR>:redraw<CR>/\[\u\]\zs.*
nnoremap <unique> <leader>fc :ExpjGotoCurrentFile<CR>
let g:exPJ_backto_editbuf = 1
let g:exPJ_close_when_selected = 0
let g:exPJ_window_width = 30
let g:exPJ_window_width_increment = 50
" ------------------------------------------------------------------
" Desc: exBufExplorer
" ------------------------------------------------------------------
" NOTE: the / can be mapped to other script ( for example exSearchComplete ), so here use nmap instead of nnoremap
if has("gui_running") " the <alt> key is only available in gui mode.
if has ("mac")
nmap <unique> ı :EXBufExplorer<CR>:redraw<CR>/
else
nmap <unique> <M-B> :EXBufExplorer<CR>:redraw<CR>/
" nmap <unique> <M-b> :EXBufExplorer<CR>
endif
endif
nnoremap <unique> <silent> <leader>bs :EXBufExplorer<CR>
nnoremap <unique> <leader>bk :EXAddBookmarkDirectly<CR>
let g:exBE_backto_editbuf = 0
let g:exBE_close_when_selected = 0
" ------------------------------------------------------------------
" Desc: exMarksBrowser
" ------------------------------------------------------------------
nnoremap <unique> <leader>ms :ExmbToggle<CR>
let g:exMB_backto_editbuf = 0
let g:exMB_close_when_selected = 0
let g:exMB_window_direction = 'bel'
" ------------------------------------------------------------------
" Desc: exEnvironmentSetting
" NOTE: The exEnvironmentSetting must put at the end of the plugin
" settings. It may update the default settings of plugin above
" ------------------------------------------------------------------
"
let g:exES_project_cmd = 'EXProject'
" NOTE: if you have different programme path and settings, pls create your own vimrc under $HOME, and define these variables by yourself.
" And don't forget sourced this rc at the end.
" web browser option: 'c:\Program Files\Mozilla Firefox\firefox.exe'
if has("gui_running")
if has("win32")
let g:exES_WebBrowser = 'c:\Users\Johnny\AppData\Local\Google\Chrome\Application\chrome.exe'
let g:exES_ImageViewer = $EX_DEV.'/tools/IrfanView/i_view32.exe'
elseif has("unix")
let g:exES_WebBrowser = 'firefox'
elseif has("mac")
let g:exES_WebBrowser = 'open'
let g:exES_ImageViewer = 'open'
endif
endif
" exEnvironmentSetting post update
" NOTE: this is a post update environment function used for any custom environment update
function g:exES_PostUpdate()
" set lookup file plugin variables
if exists( 'g:exES_LookupFileTag' )
let g:LookupFile_TagExpr='"'.g:exES_LookupFileTag.'"'
if exists(':LUCurFile')
" NOTE: the second <CR>, if only one file, will jump to it directly.
unmap gf
nnoremap <unique> <silent> gf :LUCurFile<CR>
endif
endif
" set visual_studio plugin variables
if exists( 'g:exES_vsTaskList' )
let g:visual_studio_task_list = g:exES_vsTaskList
endif
if exists( 'g:exES_vsOutput' )
let g:visual_studio_output = g:exES_vsOutput
endif
if exists( 'g:exES_vsFindResult1' )
let g:visual_studio_find_results_1 = g:exES_vsFindResult1
endif
if exists( 'g:exES_vsFindResult2' )
let g:visual_studio_find_results_2 = g:exES_vsFindResult2
endif
" set vimwiki
if exists( 'g:exES_wikiHome' )
" clear the list first
if exists( 'g:vimwiki_list' ) && !empty(g:vimwiki_list)
silent call remove( g:vimwiki_list, 0, len(g:vimwiki_list)-1 )
endif
" assign vimwiki pathes,
" NOTE: vimwiki need full path.
let g:vimwiki_list = [ { 'path': fnamemodify(g:exES_wikiHome,":p"),
\ 'path_html': fnamemodify(g:exES_wikiHomeHtml,":p"),
\ 'html_header': fnamemodify(g:exES_wikiHtmlHeader,":p") } ]
" create vimwiki files
call exUtility#CreateVimwikiFiles ()
endif
endfunction
" ------------------------------------------------------------------
" Desc: TagList