-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
executable file
·1145 lines (922 loc) · 30.2 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
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
" YCH vimrc
" version = 3.1
" +-----------------------------+
" | Plugins delcared in advance |
" +-----------------------------+
function! LoadProfileLoaderConfig()
if has('win32')
let configFile = $USERPROFILE.'\_profile_loader_vim_config'
else
let configFile = $HOME.'/_profile_loader_vim_config'
endif
" note: readfile fileformat should be unix
if filereadable(configFile)
for settingLine in readfile(configFile)
exec settingLine
endfor
endif
endfunction
" +---------------------+
" | Environment Setting |
" +---------------------+
let $PYTHONHOME='C:\Python27'
let $PYTHONPATH='C:\Python27\Lib'
" +-----------------+
" | General setting |
" +-----------------+
:filetype plugin on
syntax on
set matchtime=2
" for cursorhold
set updatetime=500
" Show matching parenthese.
set showmatch
set autochdir
" Makefile
au FileType make let b:match_words= 'ifeq\|ifneq\|ifdef\|ifndef:else:endif'
if has("win32")
if isdirectory("w:\\") " only use if w:\ exists
set viminfo='20,\"0,\/0 " max20 files to remember mark, not remembering registers, search history
set viminfo+=n\w:\\_viminfo
endif
endif
" set modeline
" vim: ts=2:
" :command -nargs=* Make make <args> | cwindow 3
colo default
set background=light
set autoread
filetype detect
"colorscheme desert
if has("gui_running")
set guioptions-=T
set guioptions-=m
set guioptions-=e
if has("win32")
set guifont=Consolas:h13
"set guifont=Inconsolata:h11
endif
if has("unix")
set guifont=Inconsolata\ Medium\ 23
"set guifont=Monospace\ 15
set linespace=2
endif
endif
" set swap directory
if isdirectory($TEMP)
set directory=$TEMP
endif
let g:ConqueTerm_PyExe = 'D:/Python27/python.exe'
"au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null"
call LoadProfileLoaderConfig()
set foldmethod=marker
" speed up syntax highlighting
augroup syntax_highlight_speedup
autocmd!
autocmd BufWinEnter,Syntax * syn sync minlines=500 maxlines=500
augroup END
" regular expression engine
set regexpengine=0
" +--------------+
" | User setting |
" +--------------+
let bUseGlobal = 1
" use logMsg for printing variable
let bUseLogMsg = 1
" use SIM_TRACE0 or SIM_TRACE1 for printing variable
let bUseSimTrace = 0
let bUseSystemOutPrintln = 0
let bUseConsoleLog = 1
" option to allow only tag list for 1 file
let Tlist_Show_One_File = 1
" +-------------------------+
" | Search setting/shortcut |
" +-------------------------+
set incsearch " best match so far
" make searches case-insensitive, unless they contain upper-case letters
set ignorecase
set smartcase
nnoremap n nzz
nnoremap N Nzz
" +-------------------------+
" | Screen movement setting |
" +-------------------------+
" setting relating to horizontal scroll
set sidescroll=20
set virtualedit=all
set nostartofline
" +---------------------+
" | Screen edit setting |
" +---------------------+
if has("gui_running")
if has("win32")
set lines=9999
set columns=9999
endif
endif
" no expand tab for make filetype
if has("autocmd")
autocmd FileType make set noexpandtab
autocmd FileType jade set noexpandtab
autocmd FileType pug set noexpandtab
autocmd FileType python set expandtab
autocmd FileType scala set expandtab
autocmd FileType js set expandtab
endif
" Default backspace like normal
set backspace=2
set tabstop=4
set nowrap
set fileformats=unix,dos,mac fileformat=unix " when read a dos file, read as dos format and save as dos format
set backspace=indent,eol,start
set shiftwidth=4
set autoindent " always set autoindenting on
set history=10 " keep 10 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set formatoptions=mtcql
set formatoptions+=n " also recognize list
set formatoptions-=o " no continue comment after new line
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" disable vim-go plugin version warning
let g:go_version_warning = 0
" remove trailing white space
autocmd BufWritePre *.c :%s/\s\+$//e
autocmd BufWritePre *.cpp :%s/\s\+$//e
autocmd BufWritePre *.html :%s/\s\+$//e
autocmd BufWritePre *.js :%s/\s\+$//e
autocmd BufWritePre *.erl :%s/\s\+$//e
autocmd BufWritePre *.hrl :%s/\s\+$//e
autocmd BufWritePre *.go :%s/\s\+$//e
autocmd BufWritePre *.jade :%s/\s\+$//e
autocmd BufWritePre *.java :%s/\s\+$//e
autocmd BufWritePre *.h :%s/\s\+$//e
autocmd BufWritePre *.hpp :%s/\s\+$//e
autocmd BufWritePre *.vue :%s/\s\+$//e
autocmd BufWritePre *.yaml :%s/\s\+$//e
" +--------------------------+
" | Screen movement shortcut |
" +--------------------------+
" move left, right word exclusive
nnoremap <C-Left> B
nnoremap <C-Right> W
inoremap <C-Left> <C-o>B
inoremap <C-Right> <C-o>W
" go to middle column
noremap E gm
" scroll horizontal left and right
nnoremap <S-Left> zh
nnoremap <S-Right> zl
" vertical scroll while cursor remains
nnoremap <S-Up> 1<C-U>
nnoremap <S-Down> 1<C-D>
" ctrl up and down = slightly fast up and down
nnoremap <C-Up> 10<Up>
nnoremap <C-Down> 10<Down>
" ctrl page up and down = super fast scroll
"noremap <C-PageUp> 10<PageUp>
"noremap <C-PageDown> 10<PageDown>
" shortcut for quickfix window
nnoremap <A-cr> :cw<cr>:cc<cr>
"nnoremap <A-Up> :cw<cr>:cp<cr>zz
"nnoremap <A-Down> :cw<cr>:cn<cr>zz
" if set wrap option used, then allow move to next screen line instead of physical link
nnoremap <silent> <up> gk
inoremap <silent> <up> <C-o>gk
nnoremap <silent> <down> gj
inoremap <silent> <down> <C-o>gj
nnoremap <silent> <home> ^
" scroll horizontal left and right
inoremap <S-Left> <C-o>zh
inoremap <S-Right> <C-o>zl
" vertical scroll while cursor remains
inoremap <S-Up> <C-o>1<C-U>
inoremap <S-Down> <C-o>1<C-D>
" ctrl up and down = slightly fast up and down
inoremap <C-Up> <C-o>10<Up>
inoremap <C-Down> <C-o>10<Down>
" ctrl page up and down = super fast scroll
"inoremap <C-PageUp> 10<PageUp>
"inoremap <C-PageDown> 10<PageDown>
" for viewing function name
nnoremap [[ [[<Up>
func SaveLastSearchPattern()
let g:lastSearchPattern = getreg("\/")
endfunc
func RestoreLastSearchPattern()
call setreg("\/", g:lastSearchPattern)
endfunc
" searching for date format
"nnoremap ( :call SaveLastSearchPattern()<CR>?^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]<CR>:call RestoreLastSearchPattern()<CR>
"nnoremap ) :call SaveLastSearchPattern()<CR>/^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]<CR>:call RestoreLastSearchPattern()<CR>
" +----------------------+
" | Screen edit shortcut |
" +----------------------+
nnoremap <C-Del> dw
" select the current word under cursor and copy to clipboard
nnoremap vc viw"+y
" undo like windows
inoremap <C-Z> u
" escape string in clipboard
if has('win32')
nmap ,e :let @*=escape(@*, '\\/.*$^~[]')<CR>
else
nmap ,e :let @+=escape(@+, '\\/.*$^~[]')<CR>
endif
" copying word under cursor without selecting the word, using C-c in insert mode
imap <C-c> <Right><Esc>:let curnow=col(".")<CR>vc:call cursor(0,<C-R>=curnow<CR>)<CR>i
" pasting word without moving cursor
inoremap <C-g> <Right><Esc>:let curnow=col(".")<CR>"+gP:call cursor(0,<C-R>=curnow<CR>)<CR>i
"inoremap <C-Del> <C-o>cw <-- old <c-del> command
inoremap <C-Del> x<ESC>xcw
"inoremap <C-BS> <C-W>
" cut
vnoremap <C-X> "+x
" copy
vnoremap <C-C> "+y
vnoremap <C-S> :sort u<CR>
" for shifting block
vnoremap < <gv
vnoremap > >gv
cnoremap <C-v> <C-R>=getreg('+')<CR>
cnoremap <C-c> set autochdir
cnoremap <C-j> set filetype=javascript<CR>
cnoremap <C-p> set encoding=cp936<CR>
cnoremap <C-t> set filetype=trace<CR>
cnoremap <C-u> set encoding=utf-8<CR>
cnoremap <C-o> set filetype=proto<CR>
cnoremap <C-w> filetype indent on<CR>:set filetype=html<CR>:set smartindent<CR>
" for visual bookmark
" nnoremap <silent>bc :exe 'sign unplace '.line(".")<CR>
" nnoremap <silent>bm :exe 'sign place '.line(".").' name=bookmark line='.line(".").' buffer='.winbufnr(0)<CR>
"nme <silent>PopUp.bookmark_&x :exe 'sign unplace '.line(".")<CR>
"nme <silent>PopUp.bookmark_&a :exe 'sign place '.line(".").' name=bookmark line='.line(".").' buffer='.winbufnr(0)<CR>
sign define bookmark linehl=DiffDelete
ab dt# <C-R>=strftime("%d/%m/%y")<CR>
ab tm# <C-R>=strftime("%H:%M")<CR>
"inoremap <A-Left> <C-o>10zh<CR>
"inoremap <A-Right> <C-o>10zl<CR>
" Use Ctrl-B for undo in insert mode
inoremap <C-B> <C-o>u
inoremap <C-E> <ESC>:e
inoremap <C-V> <C-o>"+gP
"inoremap <C-S> <C-o>:up<CR> <-- old <c-s> command
inoremap <C-S> x<ESC>x:up!<CR>i
" undo like windows
inoremap <C-Z> <C-O>u
" printf variable
"nmap <C-b> :let $printfSub=""<Left>
"inoremap <C-b> <C-o>:let $printfSub=""<Left>
vmap <C-d> "+y<ESC>
\o<C-R>=GetVarDebugMsg(getreg("+"))<CR><ESC>
nmap <C-d> :let $currentWord=expand("<cword>")<CR>
\o<C-R>=GetVarDebugMsg($currentWord)<CR><ESC>
vmap <C-b> "+y<ESC>
\o<C-R>=GetInDebugMsg(getreg("+"))<CR><ESC>
nmap <C-b> :let $currentWord=expand("<cword>")<CR>
\o<C-R>=GetInDebugMsg($currentWord)<CR><ESC>
vmap ,h "+y<ESC>
\o<C-R>=GetHexDebugMsg(getreg("+"))<CR><ESC>
nmap ,h :let $currentWord=expand("<cword>")<CR>
\o<C-R>=GetHexDebugMsg($currentWord)<CR><ESC>
" text zoom
nnoremap <A-=> :silent! let &guifont = substitute(&guifont, ':h\zs\d\+', '\=eval(submatch(0)+1)', '')<CR><CR>
nnoremap <A--> :silent! let &guifont = substitute(&guifont, ':h\zs\d\+', '\=eval(submatch(0)-1)', '')<CR><CR>
vnoremap bf zf
vnoremap bc zc
vnoremap bR zR
vnoremap bM zM
inoremap <f11> z
noremap bc zc
" +-----------------------------+
" | Buffer/window/file shortcut |
" +-----------------------------+
nnoremap ;s :mksession! ~/mysession.vim<CR>
nnoremap ;l :source ~/mysession.vim<CR>
" delete buffer
nnoremap bd :bd<CR>
" previous and next file in buffer
nmap <A-Left> :bp!<CR>
nmap <A-Right> :bn!<CR>
nnoremap <unique> <special> <A-[> :bn!<CR>
nnoremap <C-E> :e<Space>
" saved only when it is modified
nnoremap <C-S> :up!<CR>
" save buffer setting
cnoremap <A-w> wv!<CR>
cnoremap <A-l> call SettingForLargeFile()<CR>
" change to current directory
cnoremap <A-c> cd %:p:h<CR>
" set current directory as home directory for fzf
cnoremap <A-h> cd %:p:h<CR><ESC>mH
func GetVarDebugMsg(varName)
let varName = a:varName
if g:bUseLogMsg
let debugMsg = "logMsg(\"" . varName . " = %d (%s:%d)\\n\", " . varName .",__FILE__,__LINE__,0,0,0);"
"let debugMsg = "logMsg(\"" . varName . " = %d (%s:%d)\\n\", " . varName .",__FILE__,__LINE__);"
"let debugMsg = "qDebug() << \"" . varName . " = \" << " . varName .";"
else
let debugMsg = "printf(\"" . varName . " = %d (%s:%d)\\n\", " . varName .",__FILE__,__LINE__);"
endif
if g:bUseSimTrace
let debugMsg = "SIM_TRACE1(\"" . varName . " = %d\\n\", " . varName .");"
endif
let currentExt = expand("%:e") " filename without extension
if currentExt == "go"
let debugMsg = "logger.Trace.Printf(\"" . varName . " = %v\", " . varName .")"
endif
if currentExt == "js"
let debugMsg = "console.log(\'" . varName . " = \', " . varName .");"
endif
if currentExt == "ts" || currentExt == "vue" || currentExt == "tsx"
let debugMsg = "console.log(\'" . varName . " = \', " . varName .");"
endif
if currentExt == "java"
let debugMsg = "System.out.println(\"" . varName . " = \" + " . varName .");"
endif
if currentExt == "scala"
if match(varName, '[\.,(,)]') >= 0
let debugMsg = "println(s\"" . varName . " = ${" . varName ."}\")"
else
let debugMsg = "println(s\"" . varName . " = $" . varName ."\")"
endif
endif
if currentExt == "kt"
if match(varName, '[\.,(,)]') >= 0
let debugMsg = "println(\"" . varName . " = ${" . varName ."}\")"
else
let debugMsg = "println(\"" . varName . " = $" . varName ."\")"
endif
endif
return debugMsg
endfunc
func GetInDebugMsg(varName)
let varName = a:varName
if g:bUseLogMsg
let debugMsg = "logMsg(\"" . varName . " IN (%s:%d)\\n\",__FILE__,__LINE__,0,0,0,0);"
"let debugMsg = "logMsg(\"" . varName . " IN (%s:%d)\\n\",__FILE__,__LINE__);"
"let debugMsg = "qDebug(\"" . varName . " IN (%s:%d)\",__FILE__,__LINE__);"
else
let debugMsg = "printf(\"" . varName . " IN (%s:%d)\\n\",__FILE__,__LINE__);"
endif
if g:bUseSimTrace
let debugMsg = "SIM_TRACE0(\"" . varName . " IN\\n\");"
endif
let currentExt = expand("%:e") " filename without extension
if currentExt == "go"
let debugMsg = "logger.Trace.Printf(\"" . varName . " IN\")"
endif
if currentExt == "js"
let debugMsg = "console.log(\'" . varName . " IN\');"
endif
if currentExt == "ts" || currentExt == "vue" || currentExt == "tsx"
let debugMsg = "console.log(\'" . varName . " IN\');"
endif
if currentExt == "java"
let debugMsg = "System.out.println(\"" . varName . " IN\");"
endif
if currentExt == "scala"
let debugMsg = "pprint.pprintln(" . varName .")"
let debugMsg = "println(\"=== " . varName . " begin ===\")\r" . debugMsg
let debugMsg = debugMsg . "\rprintln(\"=== " . varName . " end ===\")\r"
endif
if currentExt == "kt"
let debugMsg = "println(\"" . varName . " IN\")"
endif
return debugMsg
endfunc
func GetHexDebugMsg(varName)
let varName = a:varName
let currentExt = expand("%:e") " filename without extension
if currentExt == "go"
let debugMsg = "Trace.HexDump(\"" . varName . "\", " . varName .")"
endif
return debugMsg
endfunc
func GetSourceFile()
let currentFileName = expand("%:r") " filename without extension
let cExt = currentFileName . '.c'
let cppExt = currentFileName . '.cpp'
let ccExt = currentFileName . '.cc'
let cExtSrcFolder = "../src/" . cExt
let cppExtSrcFolder = "../src/" . cppExt
if filereadable(cExt)
return cExt
endif
if filereadable(cppExt)
return cppExt
endif
if filereadable(ccExt)
return ccExt
endif
if filereadable(cExtSrcFolder)
return cExtSrcFolder
endif
if filereadable(cppExtSrcFolder)
return cppExtSrcFolder
endif
return ''
endfunc
func GetHeaderFile()
let currentFileName = expand("%:r") " filename without extension
let hExt = currentFileName . '.h'
let hppExt = currentFileName . '.hpp'
let hExtIncludeFolder = "../include/" . hExt
let hppExtIncludeFolder = "../include/" . hppExt
if filereadable(hExt)
return hExt
endif
if filereadable(hppExt)
return hppExt
endif
if filereadable(hExtIncludeFolder)
return hExtIncludeFolder
endif
if filereadable(hppExtIncludeFolder)
return hppExtIncludeFolder
endif
return ''
endfunc
" yank filename or filepath to clipboard
if has('win32')
nmap ,yf :let @*=substitute(expand("%"), "/", "\\", "g")<CR>
nmap ,yp :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>
nmap ,yd :let @*=substitute(expand("%:p:h"), "/", "\\", "g")<CR>
else
nmap ,yf :let @+=expand("%")<CR>
nmap ,yp :let @+=expand("%:p")<CR>
nmap ,yd :let @+=expand("%:p:h")<CR>
endif
" edit .cpp .hpp shortcut
cnoremap <C-s> <C-R>=GetSourceFile()<CR>
cnoremap <C-h> <C-R>=GetHeaderFile()<CR>
cnoremap <C-l> set list<CR>
cnoremap <C-n> set nolist<CR>
" previous and next file in buffer
imap <A-Left> <C-o>:bp!<CR>
imap <A-Right> <C-o>:bn!<CR>
if has("win32")
cnoremap <C-d> <C-R>=$USERPROFILE<CR>\Desktop
endif
" for preview window
nnoremap zp <C-w>z
" for previous quick fix result
nnoremap _ :colder<CR>
nnoremap + :cnewer<CR>
" quickfix window on
nnoremap co :cw<cr>
" quickfix window off
nnoremap cf :ccl<cr>
nnoremap <kPlus> :TlistShowPrototype<CR>
inoremap <unique> <special> <A-[> <C-o>:bn!<CR>
if has("win32")
nnoremap <A-s> :ConqueTerm cmd<CR>
elseif has("unix")
nnoremap <A-s> :ConqueTerm bash<CR>
endif
nnoremap <C-c> :let @+=expand("%")<CR>
" +--------------+
" | Tab shortcut |
" +--------------+
nmap <C-S-tab> :tabprevious<CR>
nmap <C-tab> :tabnext<CR>
map <C-S-tab> :tabprevious<CR>
map <C-tab> :tabnext<CR>
imap <C-S-tab> <Esc>:tabprevious<CR>i
imap <C-tab> <Esc>:tabnext<CR>i
nmap <C-t> :tabnew<CR>
nmap <C-n> :tabnew<CR>
nmap <C-q> :tabclose<CR>
imap <C-q> <Esc>:tabclose<CR>
" +--------------------+
" | F1 to F12 shortcut |
" +--------------------+
" set wrap option
nnoremap <F2> :set wrap<CR>
" saved and quit
nnoremap <F3> :up!<CR>:q<CR>
" no save and quit
nnoremap <F4> :q!<CR>
" refresh
nnoremap <F5> :e!<CR>
if has("win32")
nnoremap <F6> :silent !explorer /e, .<CR><CR>
endif
if has("linux")
nnoremap <F6> :silent !nautilus .<CR><CR>
endif
nnoremap <F7> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
" toggle highlight search result
nnoremap <f8> :set hls!<bar>set hls?<cr>
" toggle on/off paste mode
"noremap <f9> :set paste!<bar>set paste?<cr>
"set pastetoggle=<f9>
" Tlist
" nnoremap <silent> <f11> :Tlist<CR>:set title titlestring=%<%f\ %([%{Tlist_Get_Tag_Prototype_By_Line()}]%)<CR>
inoremap <F3> <ESC>:up!<CR>:q<CR>
inoremap <F4> <ESC>:q!<CR>
inoremap <F7> <C-R>=strftime(" /* YCH modified %d/%m/%y, ").$CS." */"<CR>
inoremap <F8> <C-R>=strftime("/* YCH modified (begin) %d/%m/%y, ").$CS." */"<CR>
inoremap <F9> <C-R>=strftime("/* YCH modified (end) %d/%m/%y, ").$CS." */"<CR>
inoremap <F10> <C-R>=strftime("/* YCH modified %d/%m/%y, ").$CS." */"<CR>
function! TraceToggleWin32()
if (&background == "dark")
colo default
set background=light
set guifont=Lucida_Console:h12:cANSI
set autoread
filetype detect
else
colo desert
set background=dark
set guifont=Consolas:h11
"set guifont=Inconsolata:h11
set noautoread
filetype detect
endif
endfunction
function! TraceToggleUnix()
if (&background == "dark")
colo default
set background=light
set autoread
filetype detect
else
colo desert
set background=dark
set guifont=Inconsolata\ Medium\ 26
set noautoread
filetype detect
endif
endfunction
function! ColorToggleWin32()
if (&background == "dark")
colo summerfruit256
set background=light
set guifont=Consolas:h10:b:cANSI
"set guifont=Inconsolata_LGC:h10:b:cANSI
set noautoread
filetype detect
else
colo desert
set background=dark
set guifont=Inconsolata:h11
set noautoread
filetype detect
endif
endfunction
" orig = function! <SID>OutlineToggle()
" Toggle syntax outline
function! OutlineToggle()
let OldLine = line(".")
let OldCol = virtcol(".")
if (! exists ("b:outline_mode"))
let b:outline_mode = 0
let b:OldMarker = &foldmarker
endif
if (b:outline_mode == 0)
let b:outline_mode = 1
set foldmethod=marker
set foldmarker={,}
silent! exec "%s/{{{/{<</"
silent! exec "%s/}}}/}>>/"
set foldcolumn=4
else
let b:outline_mode = 0
set foldmethod=marker
let &foldmarker=b:OldMarker
silent! exec "%s/{<</{{{/"
silent! exec "%s/}>>/{{{/"
set foldcolumn=0
endif
execute "normal! ".OldLine."G"
execute "normal! ".OldCol."|"
unlet OldLine
unlet OldCol
execute "normal! zv"
endfunction
"*****************************************************************
"* Commands
"*****************************************************************
":command! -nargs=0 FOLD call <SID>OutlineToggle()
" End of code
nnoremap <F12> :call EnableShiftSelect()<CR>
inoremap <F12> <C-o>:call DisableShiftSelect()<CR>
" +------------------------+
" | C-F1 to C-F12 shortcut |
" +------------------------+
nnoremap <C-F4> :color default<CR>:set background=dark<CR>
nnoremap <C-F5> :e $MYVIMRC<CR>
if has("win32")
nnoremap <C-F6> :set guifont=Courier_New:h13:cANSI<CR>
else
nnoremap <C-F6> :set guifont=Sans\ 14<CR>
endif
nnoremap <C-F7> :set guifont=Consolas:h11<CR>
"nnoremap <C-F7> :set guifont=Inconsolata:h11<CR>
if has("win32")
nnoremap <C-F8> :!start cmd .<CR>
endif
if has("win32")
nnoremap <C-F9> :call TraceToggleWin32()<CR>
endif
if has("unix")
nnoremap <C-F9> :call TraceToggleUnix()<CR>
endif
if has("win32")
nnoremap <C-F10> :call ColorToggleWin32()<CR>
endif
nnoremap <C-F11> :TidyXML<CR>:set filetype=xml<CR>
"nnoremap <C-F12> :set guifont=MingLiU:h8:cANSI<CR>:set lines=8<CR>:set columns=154<CR>:winpos 273 791<CR>
nnoremap <silent> <C-F12> :cal OutlineToggle()<CR>
" +---------------+
" | Mouse setting |
" +---------------+
" no paste text when middle wheel pressed
nnoremap <MiddleMouse> <Nop>
nnoremap <2-MiddleMouse> <Nop>
inoremap <MiddleMouse> <Nop>
inoremap <2-middlemouse> <Nop>
" +------------+
" | File search |
" +------------+
function! s:find_git_root()
return system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
endfunction
command! ProjectFiles execute 'Files' s:find_git_root()
nnoremap ,p :ProjectFiles<CR>
" +------------+
" | Tag search |
" +------------+
nnoremap ,f :call FilteringNew().addToParameter('alt', @/).run()<CR>
" using ag to search, ignore file pattern defined in ~/.agignore
let $FZF_DEFAULT_COMMAND = 'ag -g ""'
nnoremap <C-f> `H:cd %:p:h<CR>:FZF<cr>
if has("win32")
if isdirectory("w:\\")
if bUseGlobal
"set grepprg=C:\ut\global\bin\global
set grepprg=d:\ut\profile_loader\build\qTag
"set grepformat=%*[^\ ]%*[\ ]%l%*[\ ]%f%*[\ ]%m
set grepformat=%f:%l%m
"let $GTAGSDBPATH="W:\\"
if !executable(&grepprg)
let choice = confirm("Note: Program " . &grepprg . " not avaliable for tag search", "&Ok", 1)
endif
"nnoremap ;r :grep! -aGxt --result=grep <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
"nnoremap ;f :grep! -arxt --result=grep <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
"nnoremap ;s :grep! -asxt --result=grep <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
nnoremap ;r :grep! -q <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
nnoremap ;f :grep! -q <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
"nnoremap ;s :grep! -q <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
"nnoremap <C-f> :gr! -agx
"nnoremap <C-f> :gr! -arxt --result=grep
"inoremap <C-f> <C-o>:gr! -arxt --result=grep
"nnoremap <C-f> :gr! -q
"inoremap <C-f> <C-o>:gr! -q
else
" search in files for currnet word under cursor using gid
"set grepprg=lid2\ -Rgrep
set grepprg=D:\ut\mkid-win32-bin\gid
nnoremap ;a :grep! -fw:\all_id <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
nnoremap ;c :grep! -fw:\c_id <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
nnoremap ;h :grep! -fw:\h_id <c-r>=expand("<cword>")<cr><cr><cr>:cw<cr>
"nnoremap ;a :grep! -R grep -fw:\all_id <c-r>=expand("<cword>") \| ahead C:
" search in files using gid
"nnoremap <C-f> :gr! -fw:\all_id
"inoremap <C-f> <C-o>:gr! -fw:\all_id
endif
endif
endif
"if has("win32")
" set tags=./tags,w:\tags
"endif
nnoremap <C-l> :let $CS=""<Left>
inoremap <C-l> <C-o>:let $CS=""<Left>
nnoremap <C-j> :let bUseLogMsg=
inoremap <C-j> <C-o>:let bUseLogMsg=
"nnoremap <C-j> :let bUseSystemOutPrintln=
"inoremap <C-j> <C-o>:let bUseSystemOutPrintln
"nnoremap <C-j> :let bUseSimTrace=
"inoremap <C-j> <C-o>:let bUseSimTrace=
" +----------------+
" | Plugin setting |
" +----------------+
" neocomplete
let g:neocomplete#enable_at_startup = 1
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr><Up> pumvisible() ? "\<C-p>" : "\<Up>"
set completeopt-=preview
" enter for select
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
" vim go
let g:go_fmt_autosave = 0
" +------------------+
" | Screen highlight |
" +------------------+
cnoremap <C-a> :AnsiEsc<CR>
"let c_space_errors = 1 " for highlighting trailing white space
if has("gui_running")
if (exists("g:colors_name"))
if (g:colors_name == "desert")
hi TabLineFill guifg=grey30
hi TabLine guifg=grey50 guibg=grey30
hi TabLineSel guibg=grey30 guifg=grey60
endif
endif
endif
" setting for reading large file
function! SettingForLargeFile()
set ft=
set syn=
syntax off
set noswapfile
endfunction
" +---------+
" | Plugins |
" +---------+
function! EnableShiftSelect()
" for later unmap
inoremap <S-Left> <C-o>zh
inoremap <S-Right> <C-o>zl
inoremap <S-Up> <C-o><C-U>
inoremap <S-Down> <C-o><C-D>
" scroll horizontal left and right
iunmap <S-Left>
iunmap <S-Right>
" vertical scroll while cursor remains
iunmap <S-Up>
iunmap <S-Down>
behave mswin
startinsert
endfunction
function! DisableShiftSelect()
behave xterm
" scroll horizontal left and right
inoremap <S-Left> <C-o>zh
inoremap <S-Right> <C-o>zl
" vertical scroll while cursor remains
inoremap <S-Up> <C-o>1<C-U>
inoremap <S-Down> <C-o>1<C-D>
stopinsert
endfunction
" +-------------------+
" | VIM plug/ VimPlug |
" +-------------------+
call plug#begin('~/.vim/plugged')
Plug 'derekwyatt/vim-scala'
Plug 'fatih/vim-go'
Plug 'vim-scripts/Quich-Filter'
Plug 'scrooloose/nerdcommenter'
Plug 'digitaltoad/vim-pug'
Plug 'powerman/vim-plugin-AnsiEsc'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'leafgarland/typescript-vim'
Plug 'pangloss/vim-javascript'
Plug 'shime/vim-livedown'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-abolish'
Plug 'sheerun/vim-polyglot'
Plug 'dylon/vim-antlr'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
"
function! TidyXML()
silent %!xmllint --format --recover -
endfunction
command! TidyXML call TidyXML()
" +--------------------+
" | Coc |
" +--------------------+
" TextEdit might fail if hidden is not set.
set hidden
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup